-
Jan 6th, 2008, 10:08 PM
#1
Thread Starter
Lively Member
Com Port Detection
Hi,
Is there any way to detect the numbers of serial com port in my computer using visual basic ?
Thanks
-
Jan 7th, 2008, 12:31 AM
#2
Re: Com Port Detection
Originally Posted by part0
Hi,
Is there any way to detect the numbers of serial com port in my computer using visual basic ?
Thanks
Yes. You will be using MSCommControl 6.0 to do that. You can write code that will list all your comports in a list or combo box. You can also write code that returnes whether or not any of the ports are in use. MsCommControl was supplied with the Pro & Enterprise editions only. It was not included in the free and learning editions.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
-
Jan 7th, 2008, 02:43 AM
#3
Re: Com Port Detection
The simplest way would be to enumerate the values in the regisrty under:
HKEY_LOCAL_MACHINE\Hardware\DeviceMap\SerialComm
I believe that you can also enumerate them using WMI but that might be a bit of an overkill
-
Jan 7th, 2008, 11:18 AM
#4
Re: Com Port Detection
Originally Posted by Doogle
The simplest way would be to enumerate the values in the regisrty under:
HKEY_LOCAL_MACHINE\Hardware\DeviceMap\SerialComm
I believe that you can also enumerate them using WMI but that might be a bit of an overkill
I'm a bit Registry shy so I tend to stay away from those options. Off the top of my head I think you could write (with proper error handlers) code to loop through all your comports and execute a 'MSComm1.PortOpen = True' statement. Since Windows will return the error number for "Port not found", "Port In Use!", etc, you can handle all your errors or lack of them with a Select Case block.
I have a 'Find Ports' routine and will post it if I can find it.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
-
Jan 7th, 2008, 11:20 AM
#5
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Jan 8th, 2008, 11:09 AM
#6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|