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:
    
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?