Results 1 to 4 of 4

Thread: [RESOLVED] WM6 AttemptConnect not working

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Location
    Hawaii
    Posts
    24

    Resolved [RESOLVED] WM6 AttemptConnect not working

    Hi! I actually just started VB last week so please forgive me if my programming structure seems odd in any way. Anyways, I'm trying to get a SOAP call out from my WM6 phone. It works as long as the connection is up, but it drops after no activity and the only to get it back up is to go into comm manager or open up the browser. Im using VS2008 w/ the Windows Mobile 6 PRO SDK Platform.

    When i run the program I want it to Test the connection and if it isn't present then force the dial-up box up like iexplorer. I can get the connection status no problem but it's always coming up as connected to LAN(when it isn't) and InternetAttemptConnect() does nothing. I also tried InternetCheckConnection () for testing and that fails while the LAN works?! Any ideas? Thanks!

    *I tried turning active sync off on the phone..everything!! i'm out of ideas. But running internet explorer seems to get the dial-up box up and auto-connecting.

    Code:
    Private Declare Function InternetGetConnectedState Lib "wininet" (ByRef dwflags As Integer, ByVal dwReserved As Integer) As Integer
        Private Declare Function InternetAttemptConnect Lib "wininet" (ByVal dwReserved As Integer) As Integer
    
        Private Const CONNECT_LAN As Integer = 2
        Private Const CONNECT_MODEM As Integer = 1
        Private Const CONNECT_PROXY As Integer = 4
        Private Const CONNECT_OFFLINE As Integer = 20
        Private Const CONNECT_CONFIGURED As Integer = 40
        Private Const CONNECT_RAS As Integer = 10
    
        Private Function TestConnection(ByRef ConnType As String) As Boolean
            Dim dwflags As Integer
            Dim WebTest As Boolean
            ConnType = ""
            WebTest = InternetGetConnectedState(dwflags, 0)
            Select Case WebTest
                Case dwflags And CONNECT_LAN : ConnType = "LAN"
                Case dwflags And CONNECT_MODEM : ConnType = "Modem"
                Case dwflags And CONNECT_PROXY : ConnType = "Proxy"
                Case dwflags And CONNECT_OFFLINE : ConnType = "Offline"
                Case dwflags And CONNECT_CONFIGURED : ConnType = "Configured"
                Case dwflags And CONNECT_RAS : ConnType = "Remote"
            End Select
            TestConnection = WebTest
        End Function
        Private Sub CheckConnection()
            Dim msg As String = ""
            If Not TestConnection(msg) Then
                If InternetAttemptConnect(0) = 0 Then
                    MsgBox("Connection Attempted", vbInformation)
                Else
                    MsgBox("Connection Failed", vbInformation)
                End If
            Else
                If msg = "LAN" Then
                    MsgBox("Connected by LAN", vbInformation)
                    'Try connecting anyways
                    InternetAttemptConnect(0)
                Else
                    MsgBox("Connected by something else", vbInformation)
                End If
            End If
    
        End Sub

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: WM6 AttemptConnect not working

    Hey,

    You might want to have a look at the SystemState class.

    http://msdn.microsoft.com/en-us/libr...stemstate.aspx

    It has a number of properties that may be of interest to you.

    It also gives you the ability to get notified when any of these states change.

    Hope that helps!!

    Gary

  3. #3
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: WM6 AttemptConnect not working

    There is a great 'How Do I' video on connecting here
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Apr 2009
    Location
    Hawaii
    Posts
    24

    Re: WM6 AttemptConnect not working

    Thanks guys! The video was exactly what i needed!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width