Статьи по Delphi (026)…

Как корректно определить изменения в оборудовании PlugNPlay?

Как корректно определить изменения в оборудовании PlugNPlay?

Code: Type. TForm1 = class(TForm). Button1: TButton; Private. { Private declarations }. Procedure WMDeviceChange(var Message: TMessage); Message WM_DEVICECHANGE; Public. { Public declarations }. End; Var. Form1: TForm1; Implementation. {$R *.DFM}. Const DBT_DEVICEARRIVAL = $8000; Const DBT_DEVICEQUERYREMOVE = $8001; Const DBT_DEVICEQUERYREMOVEFAILED = $8002; Const DBT_DEVICEREMOVEPENDING = $8003; Const DBT_DEVICEREMOVECOMPLETE = $8004; Const DBT_DEVICETYPESPECIFIC = $8005; Const DBT_CONFIGCHANGED = $0018; Procedure TForm1.WMDeviceChange(var Message: TMessage); Var. S : string; Begin. {Do Something here}. Case Message.wParam of. DBT_DEVICEARRIVAL : S := 'A device has been inserted and is now available'; DBT_DEVICEQUERYREMOVE: begin. S := 'Permission to remove a device is requested'; ShowMessage(s); {True grants premission}. Message.Result := integer(true); Exit; End; DBT_DEVICEQUERYREMOVEFAILED : S := 'Request to remove a device has been canceled'; DBT_DEVICEREMOVEPENDING : S := 'Device is about to be removed'; DBT_DEVICEREMOVECOMPLETE : S := 'Device has been removed'; DBT_DEVICETYPESPECIFIC : S := 'Device-specific event'; DBT_CONFIGCHANGED : S:= 'Current configuration has changed' Else s := 'Unknown Device Message'; End; ShowMessage(s); Inherited; End;

©Drkb::01334.