In Windows 95/98/Me, one can enumerate the modems on a machine,
and what ports they are attached to, by examining the entries
under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\Modem\
For example, code like this generally works pretty well (search the forum
to locate the GetStringValue sub).
However, in Windows 2000 the modem info is stored elsewhere, as near
as I can tell not in the System Registry at all. Does not appear (to
me) to be available in the RAS routines either. Does anyone know
how to find, in Windows 2000, what modem is assigned to what COM
port?
------------------
Michael Burns
and what ports they are attached to, by examining the entries
under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\Modem\
For example, code like this generally works pretty well (search the forum
to locate the GetStringValue sub).
Code:
FUNCTION EnumerateModemWindowsInit (ComPortToMatch AS INTEGER, ModemInitString AS STRING,_ ModemCommandPrefix AS STRING, ModemHangUp AS STRING, ModemDialPrefix AS STRING, _ ModemDialSuffix AS STRING, ModemSpeakerOff AS STRING, ModemNum AS INTEGER) AS STRING ' ' Here we examine the Modem Registry Settings ' Find out which one is on ComPortToMatch ' and we get the Windows command strings for dialing, hanging up, ' turning off the speaker, and putting things back to the Windows ' defaults. Note that by getting the command & dial prefixes, and dial ' suffix, we are not restricted to Hayes compatible modems. ' ' EnumerateModemWindowsInit itself is a string of the description of the modem ' LOCAL I AS INTEGER LOCAL A$ LOCAL KEY$ ModemInitString="" KEY$="HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\Modem\" ModemNum=0 CheckModem: A$ = GetStringValue(KEY$+TRIM$(FORMAT$(ModemNum,"0000")), "DriverDesc") IF A$="" AND ModemNum>8 THEN FUNCTION = "" ModemInitString="" ModemCommandPrefix="" ModemHangUp="" ModemDialPrefix="" ModemDialSuffix="" ModemSpeakerOff="" EXIT FUNCTION END IF IF A$<>"" THEN FUNCTION = A$ A$ = GetStringValue(KEY$+TRIM$(FORMAT$(ModemNum,"0000")), "AttachedTo") A$=TRIM$(A$) A$=RIGHT$(A$,1) I=VAL(A$) IF I = ComPortToMatch THEN ModemInitString = GetStringValue(KEY$+TRIM$(FORMAT$(ModemNum,"0000"))+"\Init", "2") ModemInitString = REMOVE$(ModemInitString, "<cr>") ModemCommandPrefix = GetStringValue(KEY$+TRIM$(FORMAT$(ModemNum,"0000"))+"\Init", "1") ModemCommandPrefix = REMOVE$(ModemCommandPrefix, "<cr>") ModemHangUp = GetStringValue(KEY$+TRIM$(FORMAT$(ModemNum,"0000"))+"\Hangup", "1") ModemHangUp = REMOVE$(ModemHangUp, "<cr>") ModemDialPrefix = GetStringValue(KEY$+TRIM$(FORMAT$(ModemNum,"0000"))+"\Settings", "DialPrefix") ModemDialSuffix = GetStringValue(KEY$+TRIM$(FORMAT$(ModemNum,"0000"))+"\Settings", "DialSuffix") ModemSpeakerOff = GetStringValue(KEY$+TRIM$(FORMAT$(ModemNum,"0000"))+"\Settings", "SpeakerMode_Off") EXIT FUNCTION END IF END IF ModemNum=ModemNum+1 GOTO CheckModem END FUNCTION
as I can tell not in the System Registry at all. Does not appear (to
me) to be available in the RAS routines either. Does anyone know
how to find, in Windows 2000, what modem is assigned to what COM
port?
------------------
Michael Burns
Comment