Board index » cppbuilder » serial com port
John
CBuilder Developer |
John
CBuilder Developer |
serial com port |
Joe Pasquariello
CBuilder Developer |
2007-12-18 11:41:45 AM
Re:serial com port
John,
Are you using a serial comm component of some type? Does it have a method for opening a COM port? I'm using an old C++ Builder shareware component called ZComm (still available), and I use a brute-force method to make a list of available COM ports, as outlined below. Note that the resulting list will not contain COM ports that exist but are already in use. Joe for (int i=1; i<=256; i++) { if (open_com(i) == true) { add i to list close_com(i) } } "John" < XXXX@XXXXX.COM >wrote in message QuoteHow can I scan for all available serial com ports? |
Igor cardoso
CBuilder Developer |
2008-01-12 01:46:08 AM
Re:serial com port
Sorry for the delay dude, i saw your post because i was searching for
the same thing. Thats one of the ways i learned: TStringList* availableComPorts = new TStringList(); TRegistry *Registry = new TRegistry(KEY_READ); AnsiString portNb =""; Registry->RootKey = HKEY_LOCAL_MACHINE; // The com ports are administered in the following directory. // false, because no entry is supposed to be created. Registry->OpenKey("HARDWARE\\DEVICEMAP\\SERIALCOMM", false); // Extract the COM port names and store them. Registry->GetValueNames(availableComPorts); // List the available COM ports in the corresponding combo box. for (int i(0); i < availableComPorts->Count; i++) { portNb = Registry->ReadString(availableComPorts- QuoteStrings[i]); delete Registry; delete availableComPorts; {smallsort} |