Re: Checking if device is docked - please help



If you resolve PPP_PEER on any version of Windows Mobile, I think you should
get something if you are docked, and nothing if you are not.

Paul T.

"Christian Resma Helle" <xtianism@xxxxxxxxx> wrote in message
news:%23$jwe3eIIHA.5360@xxxxxxxxxxxxxxxxxxxxxxx
If you're using Windows Mobile 5.0 or higher then you should check out the
CradlePresent SystemState from the SNAPI (Microsoft.WindowsMobile.Status)

--
Regards,
Christian Resma Helle
http://christian-helle.blogspot.com


"Rob S" <RobS@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F8294B34-062F-45FE-9F1E-196E5E5C843A@xxxxxxxxxxxxxxxx
This is driving me mad, i'm using the below code:

public static bool IsDeviceDocked()
{
bool bRetVal = false;
try
{
string sHostName = Dns.GetHostName();

IPHostEntry ipheThisHost = Dns.GetHostByName(sHostName);
IPAddress ipThisAddr = ipheThisHost.AddressList[0];

string ip = ipThisAddr.ToString();
string localhost =
IPAddress.Parse("127.0.0.1").ToString();

if (ip == localhost)
{
bRetVal = false;
}
else
{
bRetVal = true;
}
}
catch (Exception ex)
{
// TODO: Add your own exception handling here
}
return bRetVal;
}

Basically, if i start the application while it's docked then it returns
true
(as it should), if the application is started docked but then unplugged
it
still returns true, if i start it unplugged then it returns false.

What is a reliable way of telling if it's docked or not? Nothing seems to
work for me.

Thanks guys




.



Relevant Pages

  • Re: The code for "sorting in C sharp considered superior" in five parts for easier download
    ... // Convert times to string ... public static bool errorHandler ... int intLeft, int intTop, ... // screenWidth and screenHeight). ...
    (comp.programming)
  • Re: SIP button invisible
    ... > private static extern IntPtr FindWindow(string className, ... > public static bool ShowStartIcon ... > SHFullScreenHelper.ShowSIPButton(Me, False) 'This hides the SIP button ... > lpClassName As String, ByVal lpWindowName As String) As IntPtr ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Cannot get MSMDARCH.exe to work or produce feedback
    ... supposed to unpack a CAB file used for an OLAP cube in MS Analysis ... public static bool unpackDTSCAB ... string MSMADataPath = ...
    (microsoft.public.sqlserver.olap)
  • Re: nvarchar parameter not truncated based on size of field
    ... ;-) Remember that most samples you're likely to see don't have a lot of the error and exception handling you'd want in a production app. ... Generally though I prefer not to use exception handling for normal data entry errors. ... what's the best practice when assigning strings to parameters? ... check the size of each string before assigning? ...
    (microsoft.public.sqlserver.ce)
  • Re: Java Reflection Exception Jungle
    ... Why FileNotFoundException cannot have a getFilemethod? ... public void startElement(String ns, String ln, String qn, Attributes as) ... The errorHandler can raise the SAXParseException. ...
    (comp.lang.java.programmer)

Loading