拦截消息WM_DEVICECHANGE即可! //响应该消息 procedure Tform1.WMDEVICECHANGE(var msgx :Tmessage); const DBT_DEVICEARRIVAL=$8000; DBT_DEVICEREMOVECOMPLETE=$8004; begin inherited; case msgx.WParam of DBT_DEVICEARRIVAL:Caption :='有了!'; DBT_DEVICEREMOVECOMPLETE:Caption :='取走了'; end; end;转自KINGRON的猛料
type TForm1 = Class(TForm) private procedure WMDeviceChange(var msg:TMessage); message WM_DEVECECHANGE; ...procedure Tform1.WMDEVICECHANGE(var msgx :Tmessage); begin inherited; case msgx.WParam of $8000:Caption :='盘插入了'; $8004:Caption :='盘取出了'; end; end;
function DiskSize(Drive: Byte): Int64; DiskSize returns the size in bytes of the specified drive, where 0 = Current, 1 = A, 2 = B, etc. DiskSize returns -1 if the drive number is invalid. 如果DiskSize(1)=-1则认为没有放软盘...
不能,能不能麻烦你转载一下,无限感谢!
或发个邮件给我也行。
[email protected]
//响应该消息
procedure Tform1.WMDEVICECHANGE(var msgx :Tmessage);
const
DBT_DEVICEARRIVAL=$8000;
DBT_DEVICEREMOVECOMPLETE=$8004;
begin
inherited;
case msgx.WParam of
DBT_DEVICEARRIVAL:Caption :='有了!';
DBT_DEVICEREMOVECOMPLETE:Caption :='取走了';
end;
end;转自KINGRON的猛料
TForm1 = Class(TForm)
private
procedure WMDeviceChange(var msg:TMessage); message WM_DEVECECHANGE;
...procedure Tform1.WMDEVICECHANGE(var msgx :Tmessage);
begin
inherited;
case msgx.WParam of
$8000:Caption :='盘插入了';
$8004:Caption :='盘取出了';
end;
end;
DiskSize returns the size in bytes of the specified drive, where 0 = Current, 1 = A, 2 = B, etc. DiskSize returns -1 if the drive number is invalid.
如果DiskSize(1)=-1则认为没有放软盘...
我试了一下,不行,能不能更详细一点。谢谢。