Tech Off Post

Single Post Permalink

View Thread: Retrieving the External IP in WinCE
  • User profile image
    NotSoTragic​Hero

    davewill said:

    Sounds like you don't need anything fancy.  Here is a down and dirty.  New .NET CE project with Form1, add textbox1 (multiline) and 1 button.  Basic code found in help file for WebRequest.

     

     

     

     

     

     

     

     

     

     

     

     

    Imports

     

    System.Net

     

    Imports

     

    System.IO

     

    Public

     

     

     

    Class Form1Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click' Create a request for the URL.

     

     

     

     

    Dim request As WebRequest = WebRequest.Create("http://www.whatismyip.com")' If required by the server, set the credentials.

     

    request.Credentials = CredentialCache.DefaultCredentials

     

     

    ' Get the response.

     

     

     

     

    Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)' Display the status.

     

    TextBox1.Text =

     

     

    "Status=" & response.StatusDescription' Get the stream containing content returned by the server.

     

     

     

     

    Dim dataStream As Stream = response.GetResponseStream()' Open the stream using a StreamReader for easy access.

     

     

     

     

    Dim reader As New StreamReader(dataStream)' Read the content.

     

     

     

     

    Dim responseFromServer As String = reader.ReadToEnd()' Display the content.

     

    TextBox1.Text &= responseFromServer

     

     

    ' Cleanup the streams and the response.

     

    reader.Close()

    dataStream.Close()

    response.Close()

    TextBox1.SelectionStart = TextBox1.Text.IndexOf(

    TextBox1.ScrollToCaret()

     

    End

     

    "Your IP Address Is", StringComparison.InvariantCultureIgnoreCase)

    End Sub

    End Class

     

    Edit: Code insert thingy butchered the code.  figured a basic paste was more readable.

    Thanks for your help once again.   Big Smile

     

    That worked beautifully.  However, it looks as if the modem isn't letting me remotely connect to my device through it Sad