Results 1 to 8 of 8

Thread: VB 6.0 Comm Port number higher than 16

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    150

    VB 6.0 Comm Port number higher than 16

    So I'm fighting the Windows issue where it keeps incrementing the comport number because I'm constantly insert / remove devices, and even though I remove the hidden ones, it climbs above 16 sometimes. I've got 4 different stations where this program needs to run, and they are having the same issue.

    I found a "workaround" to "repair" the c:\Windows\SysWow64\MSCOMM32.0CX (Win10 O.S.) by editing the hex values. Searched for the hex pattern [3D 10 00] and then replace the middle value 0x10 (16) with 0x63 (99) then I can use higher numbers for my serial ports. Also found that pattern in TWO places in the MSCOMM32.OCX file, one at Row 08F0 and one at Row 3C00, only need to change the 2nd one.

    Anyway, it seems to work, and I'm using higher baud rates (115,200) too, everything seems solid with my reliability testing...but I'd feel a lot better if some of you'all chimed in and said this was a good idea. I know its a hack, little bit ashamed of that...

    open to a better solution for sure, I'm not a good programmer at all...

    Edited to fix the swapped hex/dec values...my bad.
    Last edited by prginocx; Mar 16th, 2022 at 09:59 AM. Reason: Fix my mistake

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB 6.0 Comm Port number higher than 16

    I know people have done this a lot, and I've never heard of trouble.

    You have your hex and decimal values inverted, but aside from that using 99 as the limit is likely safe.

    The limit of 16 was probably a holdover from old 16-bit VBX code. If VB had not been killed off Microsoft probably would have updated the OCX's limit in a later VB version.

  3. #3
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,163

    Re: VB 6.0 Comm Port number higher than 16

    Try this in a command prompt

    Code:
    c:> reg query HKLM\Hardware\DeviceMap\SerialComm
    
    HKEY_LOCAL_MACHINE\Hardware\DeviceMap\SerialComm
        \Device\Serial0    REG_SZ    COM3
        \Device\Nmserial0    REG_SZ    COM1
        \Device\Nmserial1    REG_SZ    COM2
    COMx is just a mapping so you can change the actual number either in Device Manager (there is an UI for this) or directly through registry.

    cheers,
    </wqw>

  4. #4
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,399

    Re: VB 6.0 Comm Port number higher than 16

    There was, and probably still is, a way to limit the COM port numbers:

    Windows XP Phantom USB/Bluetooth COM Port Deletion
    Windows XP uses a sequential numbering scheme to assign port numbers to virtual COM
    ports, which due to a bug in the way ports are assigned and deleted, can result in the
    assignment of silly numbers like COM 67, etc. This in turn often creates problems with
    certain applications that only recognise a limited range of COM port IDs (20 is an often
    seen limit). You may use RegEdit to reset this value—however it is an all or nothing
    process, I.e. devices you wish to keep will have to be reinstalled.
    NOTE: Make a backup of the registry prior to taking any of the following steps.
    You edit the registry at your own risk.
    The first step in removing the phantom ports is to uninstall all USB/Bluetooth COM ports
    using the Windows Device Manager. Unfortunately XP does not reset the COM Name
    Arbiter registry entry when you delete ports with the Device Manager—this is the root of the
    problem….
    The process described below explains how to reset the COM Name Arbiter entry to bring
    things back down to earth, and suggests two other registry keys that may also be edited to
    provide additional clarity to the operating system.
    Run RegEdit—then navigate to:
    HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/COM Name Arbiter
    There will be a value key named COMDB, and if you are experiencing the crazy high COM
    port numbers the value will be FF FF B3 00 or something like that. This is a bit map of the
    assigned COM port numbers, a set bit indicates an assigned port number. The bits in each
    byte are interpreted in classic right to left fashion where bits 0..7 of the first byte represent
    COM 1..8, bits 0..7 of byte two are COM 9 to COM 16, etc. This is somewhat
    counterintuitive and a bit (no pun intended) “backwards”.
    Reset the value to represent the number of physical COM ports on you machine. If you
    have one port the value should be 01 00 00 00 (bit 0 of the first byte is set), if two then set
    the value to 03 00 00 00 (bits 0 and 1 of the first byte set).
    You may also want to clean any non-standard or unwanted virtual serial ports from these
    registry keys:
    HKEY_LOCAL_MACHINE/HARDWARE/DEVICEMAP/SERIALCOMM
    HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Ports
    The first contains the descriptive strings and port names that appear in some dropdowns
    and system utilities--the second contains a list of all I/O ports, apparently ever named by
    the system.
    These latter entries seem to have no effect on anything that I can find, not even the device
    lists offered by any XP dialogs or utilities. It must be some leftover Windows NT thing.
    Restart your computer and reinstall your desired USB and Bluetooth serial emulation
    devices, they will now have more sensible numbers.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    150

    Re: VB 6.0 Comm Port number higher than 16

    Quote Originally Posted by wqweto View Post
    Try this in a command prompt

    Code:
    c:> reg query HKLM\Hardware\DeviceMap\SerialComm
    
    HKEY_LOCAL_MACHINE\Hardware\DeviceMap\SerialComm
        \Device\Serial0    REG_SZ    COM3
        \Device\Nmserial0    REG_SZ    COM1
        \Device\Nmserial1    REG_SZ    COM2
    COMx is just a mapping so you can change the actual number either in Device Manager (there is an UI for this) or directly through registry.

    cheers,
    </wqw>

    Under Properties --> Advanced it is showing they are all in use ? Is there a way to get rid of these since I know they don't exist / are not used ? Or is that editing the registry ?

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    150

    Re: VB 6.0 Comm Port number higher than 16

    Do you'all recommend some other .ocx ? Maybe one that likes Win10 better ?

  7. #7
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,399

    Re: VB 6.0 Comm Port number higher than 16

    Set Device Manager to Show Hidden Devices, then you can delete them.

    https://winaero.com/how-to-view-hidd...hat&#39;s%20it.

    With a registry edit, you may be able to prevent COM port numbers above a selected value from being assigned, see my previous post.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jan 2008
    Posts
    150

    Re: VB 6.0 Comm Port number higher than 16

    Quote Originally Posted by jdc2000 View Post
    Set Device Manager to Show Hidden Devices, then you can delete them.

    https://winaero.com/how-to-view-hidd...hat&#39;s%20it.

    With a registry edit, you may be able to prevent COM port numbers above a selected value from being assigned, see my previous post.


    " Yeah, I have it set to show hidden, and I do delete them on a regular basis...I'm going to look into registry edit, thanks... "

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width