• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 

How to detect a new serial port has been created ...

Started by Roman Novgorodov, April 25, 2008, 03:04:54 pm

Previous topic - Next topic

Roman Novgorodov

Hello

Every time when your windows system changes its hardware configuration, it sends WM_DEVICECHANGE message for all runned applications.

You can process this message in your main form like it is done in the following code:



unit Unit1;
interface
  ...
Type
  TForm1 = class(TForm)
   ...
  public       
    procedure WMDeviceChange(var Msg:TMessage); message WM_DEVICECHANGE;     
  end;

implementation

{$R *.dfm}
...

procedure TForm1.WMDeviceChange(var Msg: TMessage);
begin
  nrComm1.WMDeviceChange(Msg);
end;

end.



The TnrComm class and most of other classes from nrComm Lib have method WMDeviceChange() that helps to process WM_DEVICECHANGE message and reloads internal device list of component.

Roman Novgorodov
DeepSoftware.Com

Quote
is there a way for the application to detect a new port has been
created, like when a USB-RS232 cable is plugged in?  Or should I just poll
for it?
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.