上次寫(xiě)了個(gè)CD/DVD -> ISO 的工具,不過(guò)似乎有點(diǎn)小問(wèn)題,重寫(xiě)了一個(gè)修正版。
2008-01-14
[*] 修正了時(shí)間顯示部分
[*] 修正了版本顯示部分
[*] 提高了數(shù)據(jù)寫(xiě)入速度
[+] 增加了寫(xiě)入速率顯示
[+] 加入在線版本檢查功能
2007-4-25
[*] 修改版本號(hào)為1.0,并使用"主.年.月.日"格式
[+] 添加刷新按鈕,用來(lái)刷新驅(qū)動(dòng)器列表
[+] 用不同的圖標(biāo)區(qū)分DVD和CD,且有光盤和無(wú)光盤時(shí)也不同
TODO:
某些系統(tǒng)下不會(huì)自動(dòng)刷新驅(qū)動(dòng)器列表
核心代碼
procedure TISOMaker.Build(Drive: Char; FileName: string; BufferSize: DWORD);
var
hDrive, hFile: THandle;
Buffer: array of Byte;
Readed: Cardinal;
Count,
Total: Int64;
begin
hFile := CreateFile(PChar(FileName), GENERIC_WRITE, FILE_SHARE_READ, nil, CREATE_ALWAYS, 0, 0);
if hFile = INVALID_HANDLE_VALUE then
raise Exception.CreateFmt('創(chuàng)建文件 %s: 失敗', [FileName]);
hDrive := CreateFile(PChar('\\.\' + Drive + ':'), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0);
if hDrive = INVALID_HANDLE_VALUE then
begin
CloseHandle(hFile);
raise Exception.CreateFmt('打開(kāi)驅(qū)動(dòng)器 %s: 失敗', [Drive]);
end;
FDrive := Drive;
FAborted := False;
try
Count := 0;
Total := GetDriveSize(Drive);
GetMem(Buffer, BufferSize);
while not FAborted and ReadFile(hDrive, Buffer[0], BufferSize, Readed, nil) and (Readed > 0) do
begin
Inc(Count, Readed);
DoProgress(Count, Total);
WriteFile(hFile, Buffer[0], Readed, Readed, nil);
end;
finally
CloseHandle(hFile);
CloseHandle(hDrive);
FreeMem(Buffer, BufferSize);
DoProgress(0, 0);
FDrive := #0;
end;
end;