From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect a device is plugged in a COM or a USB port?

Hope that when a device plugging in a COM or the USB port on the PC, the CVI application can catch the event. Due to the application is a windows service mode, so I think use the GetCVIWindowHandle() function to specify a particular Window to receive the message. But no idea to achieve this.

 

 

David

0 Kudos
Message 1 of 4
(4,628 Views)

HI,

    you can try WM_DEVICECHANGE.

    http://www.codeproject.com/Articles/14500/Detecting-Hardware-Insertion-and-or-Removal

   Hope to be helped somewhat to you.

0 Kudos
Message 2 of 4
(4,596 Views)

ls`s method is the key. You can also read this paper about the  WM_DEVICECHANGE event in CVI. https://decibel.ni.com/content/docs/DOC-22836

0 Kudos
Message 3 of 4
(4,570 Views)

Hello,

 

Due to the code phase will work in the Windows service mode, so the visible panel will be not  a good way. I think that to use GetCVIWindowHandle() to specify a OS window, and use RegisterWinMsgCallback() to receive the WM_DEVICECHANGE, but no idea. Do you have any suggestion?

 

 

David

0 Kudos
Message 4 of 4
(4,562 Views)