locked
how to detect the available network connection in pocketpc RRS feed

  • Question

  • is there any sample code to detect whether wifi or gprs connection is existing in pocketpc or not

    help me

    thanks

    Friday, September 15, 2006 4:03 AM

Answers

  • Hi laja,

    as far as WIFI is concerned do you mean you want to know if the WIFI device is turned on/off?

    Or do you want to know if it is connected to an AP (with a specific SSID or without worrying about its SSID)?

    Anyway, you could examine the OpenNetCF (http://www.opennetcf.org)

     

    Gian Paolo Costantino

    Friday, September 15, 2006 7:21 AM

All replies

  • Hi laja,

    as far as WIFI is concerned do you mean you want to know if the WIFI device is turned on/off?

    Or do you want to know if it is connected to an AP (with a specific SSID or without worrying about its SSID)?

    Anyway, you could examine the OpenNetCF (http://www.opennetcf.org)

     

    Gian Paolo Costantino

    Friday, September 15, 2006 7:21 AM
  • Hi Laja,

    If you want to check the Gprs Connection is available or not in your application you can use unmanaged code.

    Hope this one works for you...


    [DllImport("wininet.dll")]
    private extern static bool InternetGetConnectedState(out int Description, int ReservedValue );

    public
    static bool IsConnectedToInternet( )
    {
    //value which wilbe returned
    bool valres= true;

    try
    {
    int Desc ;

    //returns true if the Connection is available or else false
    valres = InternetGetConnectedState( out Desc, 0 ) ;
    }
    catch(Exception ex)
    {
    MessageBox.Show(ex.ToString());
    }
    return valres;
    }

    Cheers
    Biju S Melayil

    Friday, September 15, 2006 9:42 AM
  • You may also try this one:
    Note: Using this code, you won't be able to tell how the connection was made actually -       gprs, wifi,...

    bool IsConnected
    {
            get
            {
                    try
                    {
                            string hostName = Dns.GetHostName();
                            IPHostEntry curHost = Dns.GetHostByName(hostName);
                            return curHost.AddressList[0].ToString() != IPAddress.Loopback.ToString();
                    }
                    catch
                    {
                            return false;
                    }
            }
    }

    Friday, September 15, 2006 11:50 AM
  • thanks,its working.But ,its checking whether internet is connected or not.I need ,to detect or list out current available networks in our pocketpc.

    THANKS

    regards

    laja

    Tuesday, September 19, 2006 2:37 AM
  •  Biju S Melayil wrote:

    Hi Laja,

    If you want to check the Gprs Connection is available or not in your application you can use unmanaged code.

    Hope this one works for you...


    [DllImport("wininet.dll")]
    private extern static bool InternetGetConnectedState(out int Description, int ReservedValue );

    public
    static bool IsConnectedToInternet( )
    {
    //value which wilbe returned
    bool valres= true;

    try
    {
    int Desc ;

    //returns true if the Connection is available or else false
    valres = InternetGetConnectedState( out Desc, 0 ) ;
    }
    catch(Exception ex)
    {
    MessageBox.Show(ex.ToString());
    }
    return valres;
    }

    Cheers
    Biju S Melayil



    Hi Biju,

    The function IsConnectedToInternet is not returning correct status? I have used it the same way as it has been shown in the sample. It always returns the status as connected to Internet. How to simulate a situation when it will return false? Even if I am setting the Pocket Pc Device Simulator to Flight Mode, still it says its connected to internet. Please help me once again.

    Does GPRS and Internet Connectivity mean the same thing for Smart Devices? I thought, GPRS has something to do with the Network Connectivity.

    Regards,
    Suman

    Wednesday, September 20, 2006 12:30 PM
  • I have the same problem ...tried your solutions but I am connected through a dial-up connection using a mobile phone via bluetooth. When connection is lost or closed on the phone the IP from the ISP remains in my application and it is therefor unable to detect the disconnection that way . More ideas... Badly needed...

    Friday, October 20, 2006 12:58 PM
  • Hi,

     

    I'm pretty much entangled with the same issue.. We are using Windows Mobile application and not a web based application.. So is there a way I can detect the network connectivity, available or not from the windows based PDA application... Please throw light...

     

    Thanks

    Praveen Ganjam

     

    Wednesday, August 8, 2007 9:59 AM
  • Check the Microsoft.WindowsMobile.Status namespace that comes with the WM5 SDK. You'll be surprised. These webcasts are very useful
    http://channel9.msdn.com/ShowPost.aspx?PostID=271890


    Otherwise OpeNetCF has a connection manager class that can get network  information and manage opening and closing connections.
    Saturday, August 11, 2007 2:37 AM