>You can read from the register
>\HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System \MultifunctionAdapter\0\SerialController\...
>
You have to iterate the MultifunctionAdapter subkeys; it isn't always on the 0th key. You also have problems with this approach where the serial port is provided through USB emulation or redirection of IRQ 14.
The easiest way to detect this is to iterate the port using MSComm and trap the error from PortOpen:
LOCAL oComm, i, cOldErrorHandler
DECLARE aComPorts[16]
aComPorts = .T.
cOldErrorHandler = ON('ERROR')
FOR i = 1 TO 16
oComm = CREATE('MsCOMMLib.Mscomm')
oComm.CommPort = i
ON ERROR aComPorts[i] = .F.
oComm.PortOpen = .t.
oComm.PortOpen = .f.
oComm = NULL
ON ERROR &cOldErrorHandler
ENDFOR
The array aComPorts will have .t. for each available comm port.