PC Review


Reply
Thread Tools Rate Thread

Checking if device is docked - please help

 
 
=?Utf-8?B?Um9iIFM=?=
Guest
Posts: n/a
 
      8th Nov 2007
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
 
Reply With Quote
 
 
 
 
Christian Resma Helle
Guest
Posts: n/a
 
      8th Nov 2007
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" <(E-Mail Removed)> wrote in message
news:F8294B34-062F-45FE-9F1E-(E-Mail Removed)...
> 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



 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      8th Nov 2007
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" <(E-Mail Removed)> wrote in message
news:%23$(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:F8294B34-062F-45FE-9F1E-(E-Mail Removed)...
>> 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

>
>



 
Reply With Quote
 
=?Utf-8?B?Um9iIFM=?=
Guest
Posts: n/a
 
      8th Nov 2007
Thanks, that works perfectly.

"Christian Resma Helle" wrote:

> 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" <(E-Mail Removed)> wrote in message
> news:F8294B34-062F-45FE-9F1E-(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking if USB device is plugged in beaker Microsoft C# .NET 2 13th Nov 2006 11:10 PM
Q: Accessing MSMQ on WinXP Pro from a docked WM5 device Adam Bradley Microsoft Dot NET Compact Framework 11 13th Oct 2006 07:57 AM
Checking password protection on the device =?Utf-8?B?UmFqIEt1bWFy?= Microsoft Dot NET Compact Framework 4 5th Oct 2004 10:53 PM
Printing: Checking device margins Max Moor Microsoft Access Reports 0 8th May 2004 12:45 AM
checking device drivers Stacey Windows XP Drivers 0 18th Oct 2003 04:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:11 PM.