vlkc Posted October 2, 2020 Share Posted October 2, 2020 Hello, Does anybody know how to monitor COM? Here is the sample: { Some applications need to know when the user inserts or removes a compact disc or DVD from a CD-ROM drive without polling for media changes. Windows provide a way to notify these applications through the WM_DEVICECHANGE message. } type TForm1 = class(TForm) private procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE; public end; {...} implementation {$R *.DFM} procedure TForm1.WMDeviceChange(var Msg: TMessage); const DBT_DEVICEARRIVAL = $8000; // system detected a new device DBT_DEVICEREMOVECOMPLETE = $8004; // device is gone var myMsg: string; begin inherited; case Msg.wParam of DBT_DEVICEARRIVAL: myMsg := 'CD inserted!'; DBT_DEVICEREMOVECOMPLETE: myMsg := 'CD removed!'; end; ShowMessage(myMsg); end; How to realize it in UniGui ServerModule? { Some applications need to know when the user inserts or removes a compact disc or DVD from a CD-ROM drive without polling for media changes. Windows provide a way to notify these applications through the WM_DEVICECHANGE message. } type TUniServerModule = class(TUniGUIServerModule) private procedure WMDeviceChange(var Msg: TMessage); message WM_DEVICECHANGE; public end; {...} implementation {$R *.DFM} procedure TUniServerModule.WMDeviceChange(var Msg: TMessage); const DBT_DEVICEARRIVAL = $8000; // system detected a new device DBT_DEVICEREMOVECOMPLETE = $8004; // device is gone var myMsg: string; begin inherited; case Msg.wParam of DBT_DEVICEARRIVAL: myMsg := 'CD inserted!'; DBT_DEVICEREMOVECOMPLETE: myMsg := 'CD removed!'; end; ShowMessage(myMsg); end; I this way does not work Please help. Quote Link to comment Share on other sites More sharing options...
alfr Posted October 2, 2020 Share Posted October 2, 2020 Not sure I understood the use of CD in combination with unigui. But you can’t push data from the server to the various client sessions, instead the clients needs to pull the data/info from the server. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted October 3, 2020 Share Posted October 3, 2020 @vlkc, From your title request, for monitoring COM port, you have an excellent library http://nrcommlib.com/nrcomm/index.html it contains a huge of components. Some of them work fine with unigui (as they are not GUI). That said, this will work only in server side ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.