Procedure TForm1.SetDriveToStrings(aBuf: PChar; aStrings: TStrings);
Begin
If Assigned(aBuf) Then
While aBuf^ <> #0 Do Begin
aStrings.Add(aBuf);
aBuf:= StrEnd(aBuf)+1;
End;
End;
procedure TForm1.Button2Click(Sender: TObject);
var
aBuf: PChar;
DrvList: TStringList;
bytesNeeded: DWORD;
i: Integer;
Begin
DrvList := TStringList.create;
bytesNeeded := GetLogicalDriveStrings(0 , nil);
aBuf := StrAlloc(bytesNeeded + 1);
try
GetLogicalDriveStrings(bytesNeeded, aBuf);
SetDriveToStrings(pBuf, DrvList);
for i:=0 to DrvList.count-1 do begin
if GetDriveType(PChar(DrvList.Strings[i]) = DRIVE_CDROM then begin
// Yes. CDROM !!!
end;
finally
StrDispose(aBuf);
end;
end;
Source : borland.public.delphi.winapi searched by groups.google.com
도움이 되길 바랍니다
이준해
1. Drive 목록 구하기
Procedure TForm1.SetDriveToStrings(aBuf: PChar; aStrings: TStrings);
Begin
If Assigned(aBuf) Then
While aBuf^ <> #0 Do Begin
aStrings.Add(aBuf);
aBuf:= StrEnd(aBuf)+1;
End;
End;
procedure TForm1.Button2Click(Sender: TObject);
var
aBuf: PChar;
DrvList: TStringList;
bytesNeeded: DWORD;
i: Integer;
Begin
DrvList := TStringList.create;
bytesNeeded := GetLogicalDriveStrings(0 , nil);
aBuf := StrAlloc(bytesNeeded + 1);
try
GetLogicalDriveStrings(bytesNeeded, aBuf);
SetDriveToStrings(pBuf, DrvList);
for i:=0 to DrvList.count-1 do begin
if GetDriveType(PChar(DrvList.Strings[i]) = DRIVE_CDROM then begin
// Yes. CDROM !!!
end;
finally
StrDispose(aBuf);
end;
end;
Source : borland.public.delphi.winapi searched by groups.google.com
도움이 되길 바랍니다
이준해