-
February 15th, 2006, 01:50 AM
#1
How to change COM port number
I need to write a program in VB6 to list all of the available COM ports on a
computer and allow the operator to change the COM port number. I can get the list of available COM ports using the WMI but how to I change the COM port number?
I have to support a legacy program that looks for connections to devices on
specific com ports. Genius that this original programmer was, he hard coded
those com port numbers.
Currently we use a Digi edgeport with 4 serial ports. The Edgeport comes
with a utility that allows you to change the COM port numbers. However we
would like to move to single USB to serial devices (serialized of course),
which do not provide the same type of utility. I would like to write a VB6
program to help with setup by allowing the user to connect a terminator to a
serial port, send a message out to each available com port, and look for the
response. Once the user identifies the serial port I want to allow them to
change the com port number to one of the hard coded ports.
Of course they could use the device manager to change the com port numbers but I wanted to make an automated, easy to use utility, since the users will not be computer savy.
Any ideas?
Thanks,
quantum1976
-
February 15th, 2006, 04:08 AM
#2
Re: How to change COM port number
Welcome to CodeGuru!
If the port numbers are changable via system settings, then I'd guess the numbers would be in the registry. Doesn't the system require a restart when the numbers are changed though? Anyway perhaps you can locate the data in the registry and make the changes there. I don't know if there is any API for changing such port settings.
Seems to me though that such changes could cause problems depending on the circumstances. Given the non-computer savviness of the target users, this sounds like trouble to me.
Actually, the first thing that I was thinking was to locate the hard-coded values in the exe file, and write a little app to modify those instead.
Don't you have the source code for the app?
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
February 16th, 2006, 12:41 AM
#3
Re: How to change COM port number
I've given up on trying to do this through the registry, way too many keys to update.
What I would like to do now is to programmatically bring up the Advanced Settings window under the Device Manager for the serial port. I can get to the COM Port Properties window by using:
shell("rundll32.exe devmgr.dll,DeviceProperties_RunDLL /DeviceID acpi\pnp0501\1"
But I still have to click on the Port Settings tab followed by the Advanced button. Does anyone know of another way to get to the Advanced Settings window automatically?
Thanks,
quantum1976
-
February 16th, 2006, 03:54 AM
#4
Re: How to change COM port number
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
-
February 21st, 2025, 11:55 AM
#5
Re: How to change COM port number
I had a problem where DeviceManager assigned two COM3 ports which caused COM port contention when my applications tried
to use COM3, in my research I found that the registry HKLM\HARDWARE\DEVICEMAP\SERIALCOMM is where DeviceManager registers
all the COM ports. I programmatically in C# changed COM3 on one of the two designations to another unused COM port that I discovered
in the DeviceManager COM Port - Properties/Advanced settings com listbox. After the COM port change in the registry of the COM3 value (do not change the name), rebooting the PC did not revert DeviceManager back to the old settings, the new setting remained. Testing again with my applications revealed no more COM port contention on COM3.
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
|