Thread View: borland.public.cppbuilder.internet.socket
3 messages
3 total messages
Started by John
Mon, 17 Dec 2007 22:36
serial com port
Author: John
Date: Mon, 17 Dec 2007 22:36
Date: Mon, 17 Dec 2007 22:36
4 lines
992 bytes
992 bytes
How can I scan for all available serial com ports? Thanks, John
Re: serial com port
Author: Joe Pasquariello
Date: Tue, 18 Dec 2007 03:41
Date: Tue, 18 Dec 2007 03:41
27 lines
1491 bytes
1491 bytes
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" <jnguyen@teledrift.com> wrote in message
news:4766f9fb$1@newsgroups.borland.com...
> How can I scan for all available serial com ports?
>
> Thanks,
> John
>
>
Re: serial com port
Author: Igor cardoso
Date: Fri, 11 Jan 2008 17:46
Date: Fri, 11 Jan 2008 17:46
24 lines
2197 bytes
2197 bytes
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-
>Strings[i]);
ComboBox1->AddItem(portNb, NULL);
}
delete Registry;
delete availableComPorts;
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads