Solved

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

Posted on 2003-10-28
8
195 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

856 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