LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Program stops and waits for many seconds if comm port does not exist.

I'm trying to count number of comm ports on a PC, the code  below hangs for several seconds on ports that don't exist, how can I speed this up?
 
 
char *comm_port_name[]=
         {
         "",
         "com1",
         "com2",
         "com3",
         "com4",
         "com5"
         };
 
 for (i=1;i<6;i++)
  {
  comm_port_status[i] = OpenCom (i, comm_port_name[i]);
  }
0 Kudos
Message 1 of 3
(3,049 Views)

Hello,

I don't know the direct answer to your question, but if you're trying to detect the existing serial ports on a system, you could check the registry:

\HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM

Take a look at the code attached to this message. All it does is read out the registry values and put all detected serial ports into a ring control on the panel.

0 Kudos
Message 2 of 3
(3,046 Views)
OK, appearantly I forgot to attach the code Smiley Tongue
0 Kudos
Message 3 of 3
(3,043 Views)