G
Guest
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
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