Solved

How to obtain the info of modem installed in my OS?

Posted on 2003-10-28
8
194 Views
Last Modified: 2010-05-01
I want to know what modem had been installed in my os, and their state.
Some people said that they had been saved in register.
But my USB modem can be check in real time by os.
How to obtain the state of my USB modem?
0
Comment
Question by:honestman
  • 2
  • 2
8 Comments
 
LVL 48

Expert Comment

by:Mikal613
ID: 9638831
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 9638932
to see if modem is connected

 Return True if the modem is connected.
' (Actually this also returns False if there is
' an error reading the registry.)
Function ModemIsConnected() As Boolean
Dim result As Long
Dim hKey As Long
Dim lpSubKey As String
Dim phkResult As Long
Dim lpValueName As String
Dim lpReserved As Long
Dim lpType As Long
Dim lpData As Long
Dim lpcbData As Long

    ModemIsConnected = False

    lpSubKey = _
        "System\CurrentControlSet\Services\RemoteAccess"
    If RegOpenKey(HKEY_LOCAL_MACHINE, lpSubKey, phkResult) _
        <> ERROR_SUCCESS Then Exit Function

    hKey = phkResult
    lpValueName = "Remote Connection"
    lpReserved = APINULL
    lpType = APINULL
    lpData = APINULL
    lpcbData = APINULL

    If RegQueryValueEx(hKey, lpValueName, lpReserved, _
        lpType, ByVal lpData, lpcbData) _
        <> ERROR_SUCCESS _
    Then
        RegCloseKey hKey
        Exit Function
    End If
    lpcbData = Len(lpData)

    If RegQueryValueEx(hKey, lpValueName, lpReserved, _
        lpType, lpData, lpcbData) _
        <> ERROR_SUCCESS _
    Then
        RegCloseKey hKey
        Exit Function
    End If

    ModemIsConnected = (lpData <> 0)

    RegCloseKey hKey
End Function
 
 
0
 

Author Comment

by:honestman
ID: 9640067
To Mikal613:
    You have misunderstood my meaning.
    I do not want to know whether my system is connected to internet, I only wonder whether the USB modem is connected to my machine. I want to know what modem drivers are installed in my Win2000.
 
0
 

Author Comment

by:honestman
ID: 9640300
In "control panel" -> "phone and modem options" -> "Modems", It lists "The following modems are installed".
I want to know how to obtain this info in my program???
0
 
LVL 5

Accepted Solution

by:
fantasy1001 earned 250 total points
ID: 9640577
Yes, you are right, the installed modem listing is saved in registry
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\Modem\0000

Example code: have not check yet!!

Sub YourSub()
'Requires RegObj.dll

Dim objRegKey as RegObj.RegKey
Dim objRegValue as RegObj.RegValue

On Error Resume Next

Set objRegKey =
RegKeyFromString("\HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\Modem\0000")


If Err.Number =  0 Then
  For Each objRegValue in objRegKey.Values
      Select Case objRegValue.Name
          Case "ConnectedTo"
          Debug.? "Comm Port  " &  objRegValue.Value
          Case "DriverDate"
        Debug.? "Driver Date" & objRegValue.Value
          Case else
      End select
  Next

Else     Msgbox "Can't find the damn modem settings"
    Err.Clear ' I would normally Raise an error instead of the msgbox, but that is a whole other
discussion. I just put it here to

get the idea across

End If
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now