Author Topic: Launch an app on windows when a COM Port becomes available?  (Read 3504 times)

jmccabe

  • Member
  • ***
  • Posts: 6
Launch an app on windows when a COM Port becomes available?
« on: March 28, 2018, 05:08:30 pm »
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

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 2997
    • Lakeview Research

jmccabe

  • Member
  • ***
  • Posts: 6
Re: Launch an app on windows when a COM Port becomes available?
« Reply #2 on: March 29, 2018, 02:56:22 am »
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

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 2997
    • Lakeview Research
Re: Launch an app on windows when a COM Port becomes available?
« Reply #3 on: March 29, 2018, 12:43:59 pm »
Thanks, will fix.

Renate

  • Frequent Contributor
  • ****
  • Posts: 67
Re: Launch an app on windows when a COM Port becomes available?
« Reply #4 on: August 20, 2021, 06:48:39 am »
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).
« Last Edit: August 24, 2021, 11:24:06 am by Renate »