怎样监控软驱、光驱、USB接口、串口、并口???
我用下面的程序能监控到光驱、USB设备的插入与拔出,但不知道具体是光驱还是USB设备?怎么半????
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure WMDEVICECHANGE(var msgx: Tmessage); message WM_DEVICECHANGE;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
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;
end.