倾囊付出,请大家来帮忙,关于getlogicaldrives返回值的修改问题 ( 积分: 149 )

  • 主题发起人 主题发起人 ww990
  • 开始时间 开始时间
W

ww990

Unregistered / Unconfirmed
GUEST, unregistred user!
function GetNeedDrive:dword; stdcall;
var
tmpstr: string;
driver: char;
i, temp: integer;
drives: DWORD;
begin
drives := getlogicaldrives;
temp := (1 and drives);
for i := 0 to 26 do
begin
if temp = 1 then
begin
driver := char(i + integer('A'));
tmpstr := driver + ':/';
if (getdrivetype(pchar(tmpstr)) = DRIVE_CDROM) then
begin
//这里希望如果盘符类型中如有光驱
//则函数的返回值等于去除了光驱的getlogicaldrives的值;
//如我的电脑中有C:/,D:/,E:/,getlogicaldrives值是28
//去除了光驱D:/的值后,函数能返回值20
end;
end;
drives := (drives shr 1);
temp := (1 and drives);
end;

end;
 
function GetNeedDrives: DWORD;
var
i: integer;
AllDrives: DWORD;
Mask: DWORD;
DriverName: string;
begin
Result := 0;
AllDrives := GetLogicalDrives;
Mask := $4000000;
for i := 26 downto 1 do
begin
if (AllDrives and Mask) <> 0 then
begin
DriverName := Char(i + Integer('A')) + ':/';
if (GetDriveType(PChar(DriverName)) <> DRIVE_CDROM) then
Result := Result + Mask;
end;
Mask := (Mask shr 1);
end;
end;
 
接受答案了.
 
后退
顶部