線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1764
推到 Plurk!
推到 Facebook!

在 2000 下使用所有廠商光碟下控制指令讓 CD 退片正常,有些光碟機在 XP下就無法退片

尚未結案
fdia
一般會員


發表:4
回覆:12
積分:3
註冊:2002-10-09

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-11-23 07:47:31 IP:61.56.xxx.xxx 未訂閱
unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, winioctl; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure CloseDevice; function Lock:boolean; function UnLock:boolean; function Eject:Boolean; private { Private declarations } public { Public declarations } reg: DEVIOCTL_REGISTERS; hDevice: THandle; cb: DWORD; lpFileName: PChar; pb : packed record operation, NumLocks : BYTE; end; end; const Drive = 'G'; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); begin if Eject then showmessage('Ok'); end; procedure TForm1.Button2Click(Sender: TObject); begin if Lock then showmessage('ok'); end; procedure TForm1.Button3Click(Sender: TObject); begin if UnLock then showmessage('ok'); end; procedure TForm1.CloseDevice; begin CloseHandle(hDevice); end; function TForm1.Lock; begin if Win32Platform = VER_PLATFORM_WIN32_WINDOWS then begin reg.reg_EAX := $440D; //* IOCTL for block devices */ reg.reg_EBX := Ord(UpCase(Drive))-Ord ('A') 1; //* zero-based drive ID */ reg.reg_ECX := MakeWOrd($48,8); reg.reg_EDX := DWORD(@pb); pb.operation := 0; if (not Win95IOCTL(@reg)) then begin result := FALSE; exit; end; if (reg.reg_Flags and $0001) <> 0 then //* error if carry flag set */ begin result := FALSE; exit; end; Result := True; end // Windows NT (4.0 SP3) testing and corrections by Pawel Michalowski else if Win32Platform = VER_PLATFORM_WIN32_NT then begin // Using a variable assignment with lpFileName allows you to debug the // value you passed as 'Drive'. Usually due to optimization this value // would be inaccessible. (PM) lpFileName := PChar('\\.\' UpperCase(Drive) ':'); // When getting the device handle in a call to CreateFile you have to // use GENERIC_READ (0 won't work) and FILE_ATTRIBUTE_NORMAL (again 0 // won't work) (PM) hDevice := CreateFile(lpFileName, GENERIC_READ{0}, FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL{0}, 0); if hDevice = INVALID_HANDLE_VALUE{0} then begin Result := False; showmessage('error hdevice'); Exit; end; Result := DeviceIoControl(hDevice, FSCTL_LOCK_VOLUME, nil, 0, nil, 0,cb, nil); CloseHandle(hDevice); end; end; function TForm1.UnLock; begin if Win32Platform = VER_PLATFORM_WIN32_WINDOWS then begin reg.reg_EAX := $440D; //* IOCTL for block devices */ reg.reg_EBX := Ord(UpCase(Drive))-Ord ('A') 1; //* zero-based drive ID */ reg.reg_ECX := MakeWOrd($48,8); reg.reg_EDX := DWORD(@pb); pb.operation := 1; if (not Win95IOCTL(@reg)) then begin result := FALSE; exit; end; if (reg.reg_Flags and $0001) <> 0 then //* error if carry flag set */ begin result := FALSE; exit; end; Result := True; end // Windows NT (4.0 SP3) testing and corrections by Pawel Michalowski else if Win32Platform = VER_PLATFORM_WIN32_NT then begin // Using a variable assignment with lpFileName allows you to debug the // value you passed as 'Drive'. Usually due to optimization this value // would be inaccessible. (PM) lpFileName := PChar('\\.\' UpperCase(Drive) ':'); // When getting the device handle in a call to CreateFile you have to // use GENERIC_READ (0 won't work) and FILE_ATTRIBUTE_NORMAL (again 0 // won't work) (PM) ///////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// ////////// 會有可能出在這裡嗎 ???????? ///////////////// hDevice := CreateFile(lpFileName, GENERIC_READ{0}, FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL{0}, 0); if hDevice = INVALID_HANDLE_VALUE{0} then begin Result := False; showmessage('error hdevice'); Exit; end; Result := DeviceIoControl(hDevice, FSCTL_UNLOCK_VOLUME, nil, 0, nil, 0,cb, nil); CloseHandle(hDevice); end; end; function TForm1.Eject; begin if Win32Platform = VER_PLATFORM_WIN32_WINDOWS then begin reg.reg_EAX := $440D; //* IOCTL for block devices */ reg.reg_EBX := Ord(UpCase(Drive))-Ord ('A') 1; //* zero-based drive ID */ reg.reg_ECX := MakeWOrd($49,8); if (not Win95IOCTL(@reg)) then begin result := FALSE; exit; end; if (reg.reg_Flags and $0001) <> 0 then //* error if carry flag set */ begin result := FALSE; exit; end; Result := True; end // Windows NT (4.0 SP3) testing and corrections by Pawel Michalowski else if Win32Platform = VER_PLATFORM_WIN32_NT then begin // Using a variable assignment with lpFileName allows you to debug the // value you passed as 'Drive'. Usually due to optimization this value // would be inaccessible. (PM) lpFileName := PChar('\\.\' UpperCase(Drive) ':'); // When getting the device handle in a call to CreateFile you have to // use GENERIC_READ (0 won't work) and FILE_ATTRIBUTE_NORMAL (again 0 // won't work) (PM) hDevice := CreateFile(lpFileName, GENERIC_READ{0}, FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL{0}, 0); if hDevice = INVALID_HANDLE_VALUE{0} then begin Result := False; Exit; end; Result := DeviceIoControl(hDevice, IOCTL_DISK_EJECT_MEDIA , nil, 0, nil,0, cb, nil); CloseHandle(hDevice); end; end; end. I Love Sony
------
I Love Sony
fdia
一般會員


發表:4
回覆:12
積分:3
註冊:2002-10-09

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-11-23 07:53:33 IP:61.56.xxx.xxx 未訂閱
會有可能是相容性的問題嗎?? 這二台 CD/DVD-ROM 是 TEAC 8W DVD-RW - 和 LITE-ON 52WR 的燒錄機,但 TEAC DVD 在 XP/2000 下都是正常, 但 LITE-ON 52WR 在 2000 正常,但在 XP 跑程式就無法退片,但用 NERO 又可以正常退片,所以問題會出在 ASPI/NASPI 等不相容嗎??? I Love Sony
------
I Love Sony
fdia
一般會員


發表:4
回覆:12
積分:3
註冊:2002-10-09

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-11-30 04:30:57 IP:61.56.xxx.xxx 未訂閱
啊,我想問題是出在 Windows 的 Drivers Layer , 因為在 XP/2000 反覆測試, 2000 一定百發百中,XP 就會出槌個幾次, 放棄了。 就先結案喔.......... I Love Sony
------
I Love Sony
airs
一般會員


發表:7
回覆:4
積分:2
註冊:2002-08-30

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-12-27 13:54:54 IP:61.66.xxx.xxx 未訂閱
不知道你對MMC指令熟不熟 可以在退出前先下Prevent Allow Medium Removal指令(0x1E 相當於unlock碟機) 要不然也可以用Bus Trace抓看看到底兩種作業系統下的命令有沒不一樣
系統時間:2024-04-26 5:33:21
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!