Hi there,
I've got a problem that should be easy to solve, but I'm having a
nightmare in doing so.
We have an app deployed to a large number of laptops and I've
discovered a problem. We've made an assumption that the GPRS card will
always been on COM4. This isn't always the case and I need to code
something that dynamically sets the correct value in the app before
trying to dial.
The client app is in C#. I've been looking at Win32 APIs, such as
SetupDiEnumDeviceInfo and GetDefaultCommConfig, but I can't see how
these are going to help.
I've managed to get a list of all COM ports using a ManagementObject. I
know I can disregard COM1, but I could be left with more than 1 other
port, so need a way of establishing if it's the correct device. Does
anyone have any ideas how I could programatically identify a particular
piece of hardware on these COM ports?
The old VB code the app was translated from just took a list of COM
ports, disregarded COM1 and tried to open a stream on each remaining
one, 'assuming' that the first to respond was the GPRS card. This is
not reliable and I'm not happy replicating that in my code.
It's late, i'm stuck for ideas and really want to get this out the door
tomorrow. Can anyone suggest anything please that ideally doesn't
involve tons of calls to Win32 APIs, although if they're going to bring
something to the table then I'll happily go down that route.
Many thanks,
Michael.