flat assembler
Message board for the users of flat assembler.

Index > Windows > [Solved] Enumerating COM ports using Registry

Author
Thread Post new topic Reply to topic
fatygant



Joined: 12 Sep 2011
Posts: 30
Location: Poznan, Poland
fatygant 17 Jun 2013, 16:10
I am trying to get the number of serial ports available on a given machine. The method I decided to use is iterating over registry key HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM.
The assembly code for this is very simple:

Code:
virtual at rbx
  myRS232Ctrl RS232CTRL
end virtual

proc RS232Ctrl.GetPortNames
        local hKey:DWORD
        invoke  RegOpenKeyEx,\
                        HKEY_LOCAL_MACHINE,\
                        'HARDWARE\\DEVICEMAP\\SERIALCOMM',\
                        0,\
                        KEY_READ,\
                        addr hKey
        invoke  RegQueryInfoKey,\
                        [hKey],\
                        NULL,\
                        NULL,\
                        NULL,\
                        NULL,\
                        NULL,\
                        NULL,\
                        addr myRS232Ctrl.dwPortCount,\
                        NULL,\
                        NULL,\
                        NULL,\
                        NULL
        ret
endp
    

Initially I was developing my app on Windows 8 machine with MOXXA PCI-E card with two serial ports. And the above routine worked fluently. But today I switched developing to Windows 7 machine with one onboard serial port. And the result of running the above code is 0 instead of 1. I checked the Registry under HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM on both machines and I can find the proper entries there. But on Windows 7 the entry is not enumerated.

Anyone has an idea why it behaves differently on two latest Windows editions?
Post 17 Jun 2013, 16:10
View user's profile Send private message Reply with quote
fatygant



Joined: 12 Sep 2011
Posts: 30
Location: Poznan, Poland
fatygant 18 Jun 2013, 09:27
Ok - forget it. The RS232Ctrl.GetPortNames is longer than I attached above and the bug was not connected with the part I initially blamed. Shame on me for suspecting Microsoft... Smile
Post 18 Jun 2013, 09:27
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 18 Jun 2013, 12:50
fatygant wrote:
Ok - forget it. The RS232Ctrl.GetPortNames is longer than I attached above and the bug was not connected with the part I initially blamed. Shame on me for suspecting Microsoft... Smile
Thanks for updating us with the cancellation. We would have had to ask for more code anyway since what you posted was insufficient for us to test with.
Post 18 Jun 2013, 12:50
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.