Click here to Skip to main content
15,887,881 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In particular, I want to delete all traces of COMn ports that have been
uninstalled, so when my software calls EnumPorts, it will return a list
of only those serial ports that are currently implemented.

What I have tried:

Regedt32, run as Administrator. I can't delete, rename, or change anything
in this section. Typical error message: Cannot delete <key_name>: Error while
deleting key.

I scanned with RegDelNull, and it did not find any nulls in the strings.

I exported the relevant section as a .REG file, modified it according to
directions, and attempted to MERGE the modified file. The error message
included the sentence "Some keys are open by the system or other processes".

So maybe the system always has the Enum keys open.
Here is what MSDN has to say about HKEY_LOCAL_MACHINE:

...It contains subkeys that hold current configuration data, including Plug
and Play information (the Enum branch, which includes a complete list of
all hardware that has ever been on the system
), network logon preferences,...

So is there a way to delete this stuff? I don't think I can be the only
person in the world who ever wanted to do this.
Posted

In later versions of Windows some of the registry is protected. You need to assign permissions to your user to be able to delete it.

The follow article describes how to do this:

http://www.raymond.cc/blog/full-control-permission-to-delete-or-edit-restricted-windows-registry/[^]
 
Share this answer
 
Comments
John Buller 7-Jun-12 11:52am    
This is exactly what I asked for. Thanks, Stephen. Solution 2 is also excellent.

John Buller
If I was you I would take a different approach to this. I use USB COM port devices all the time and when I plug them in, some of them remember the port number they were assigned the last time they were plugged in - this is often very useful to me.

Instead of using EnumPorts try looking at PJ Naughter's solution. His article here on CP is a little dated, so you should go with the latest he has on his website (but upvote his CP solution if you like it).
EnumSerialPorts v1.02 - Enumerating Serial Ports[^]
http://www.naughter.com/enumser.html[^]

Soren Madsen
 
Share this answer
 
Comments
John Buller 7-Jun-12 12:03pm    
Many thanks, Soren. Stephen Hewison supplied the answer I wanted, and you answered another question I should have asked. I haven't looked closely at the PJ Naughter stuff yet, but it sounds just the thing I need.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900