Статьи по 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.
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
- 72.
- 73.
- 74.
- 75.
- 76.
- 77.
- 78.