Ports and Interfaces > Serial Ports

Launch an app on windows when a COM Port becomes available?

(1/1)

jmccabe:
I'm looking at the possibility of using an FTDI FT232 chip on-board some hardware so that, when it's plugged into a USB port, it will become available as a virtual COM port I'd really like this event to launch my own app on a Microsoft Windows system.

Does anyone know where I might find some information on how to cause the app to be launched? I've been searching, but most of the resources on Autoplay, for example, seem to be aimed at what to do when a USB mass storage device is connected.

Any pointers or advice gratefully appreciated.
John

Jan Axelson:
Use WMI to detect device arrival:

https://msdn.microsoft.com/en-us/library/aa393964(v=vs.85).aspx

My example code (for HID but demonstrates use):

http://janaxelson.com/hidpage.htm#MyExampleCode

https://social.msdn.microsoft.com/Forums/vstudio/en-US/f3ebf6c4-4e93-48de-b4b5-ca85ab29a376/detect-if-serial-port-has-been-removerattached?forum=vbgeneral

In the routine that detects the arrival, launch the app.

jmccabe:
Thanks for those Jan. From a brief glance, it looks like the sort of stuff I'm looking for and has certainly given me help structuring a more useful Google query. I'll take a closer look at the links and see how it goes.

As an aside, the WDK link on your example page is dead.

Thanks again.
John

Jan Axelson:
Thanks, will fix.

Renate:
You can also do this without WMI.
Use RegisterDeviceNotification, WM_DEVICECHANGE, DEV_BROADCAST_PORT

Edit: No, you don't have to register for port notifications, all top-level windows get that anyway.
(I've been registering for DEV_BROADCAST_DEVICEINTERFACE which you do need to do.)

I double-checked this by adding com ports to my UsbLog.exe
You can download that at http://www.temblast.com/windows.htm
Ok, I added volumes too (which you don't have to register to receive).

Navigation

[0] Message Index

Go to full version