Need to determine modem connect speed

How can I detect the current modem connection speed in VB?
(After DUN connnection has been established)
rmarshlAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KDivadCommented:
You can get it from the DUN Window itself by searching (using FindWindow)for it's hWnd. It's class is "#32770". You can check the caption of all Windows having this class for one starting with "Connected to ". This should be the DUN Window. Then search it's children for a control of class "Static" that has a caption starting with "Connected at ". This child control's caption will contain the connection speed.
0
rmarshlAuthor Commented:
My version of VB 6.0 does not seem to have a "FindWindow" command.

0
KDivadCommented:
FindWindow is an API. The declare (for a .bas module) is:

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

You can use:

hWnd = FindWindow("#32770", vbNullString)

to find a window, however, it returns the first one it comes across.

Give me a few minutes and I'll draw up some actual code for you.
0
KDivadCommented:
I'm sure that there is a "correct" way to do this, but this code will retreive the speed.

Paste into any module's declaration section.

Private Const GW_HWNDNEXT = 2
Private Const GW_CHILD = 5

Private Declare Function GetWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Long

Public Function ConnectAt() As Long
   
    Dim T_hWnd As Long
    Dim CT_hWnd As Long
    Dim WText As String
    T_hWnd = GetWindow(GetDesktopWindow, GW_CHILD)
    Do Until T_hWnd = 0
        WText = Space$(255)
        RetVal = GetWindowText(T_hWnd, WText, 255)
        If Left$(WText, 13) = "Connected to " Then
            CT_hWnd = GetWindow(T_hWnd, GW_CHILD)
            Do Until CT_hWnd = 0
                WText = Space$(255)
                RetVal = GetWindowText(CT_hWnd, WText, 255)
                If Left$(WText, 13) = "Connected at " Then
                    WText = Right$(WText, Len(WText) - 13)
                    Do
                        x = InStr(x + 1, WText, ",")
                        If x > 0 Then
                            WText = Left$(WText, x - 1) & Right$(WText, Len(WText) - x)
                        Else
                            Exit Do
                        End If
                    Loop
                    ConnectAt = Val(WText)
                    Exit Function
                End If
                CT_hWnd = GetWindow(CT_hWnd, GW_HWNDNEXT)
            Loop
        End If
        T_hWnd = GetWindow(T_hWnd, GW_HWNDNEXT)
    Loop

End Function


Call using:
MyConnectionSpeed = ConnectAt

Hope this helps!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.