Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / November 2007

Tip: Looking for answers? Try searching our database.

Checking if device is docked - please help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob S - 08 Nov 2007 09:37 GMT
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
Christian Resma Helle - 08 Nov 2007 10:01 GMT
If you're using Windows Mobile 5.0 or higher then you should check out the
CradlePresent SystemState from the SNAPI (Microsoft.WindowsMobile.Status)

Signature

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

> This is driving me mad, i'm using the below code:
>
[quoted text clipped - 36 lines]
>
> Thanks guys
Paul G. Tobey [eMVP] - 08 Nov 2007 15:20 GMT
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.

> If you're using Windows Mobile 5.0 or higher then you should check out the
> CradlePresent SystemState from the SNAPI (Microsoft.WindowsMobile.Status)
[quoted text clipped - 41 lines]
>>
>> Thanks guys
Rob S - 08 Nov 2007 15:26 GMT
Thanks, that works perfectly.

> If you're using Windows Mobile 5.0 or higher then you should check out the
> CradlePresent SystemState from the SNAPI (Microsoft.WindowsMobile.Status)
[quoted text clipped - 39 lines]
> >
> > Thanks guys

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.