how to开发者_StackOverflow中文版 develop small app to windows ce ,to know network availability in device using c#
( i am copying my answer to a similar question here )
Look in the registry key HKLM\system\state\connections
, there is are entries for each of the possible network types, for instance:
When connected to a wireless network:
[HKLM\system\state\Connections\Network]
Adapters="BCMSDDHD1"
Count=dword:00000001
Descriptions="Business World"
when connected to activesync:
[HKLM\system\state\Connections\Desktop]
Adapters=""
Count=dword:00000001
Descriptions="CurrentDTPTNetwork"
The Count
value under HKLM\system\state\connections
gives you the total number of active connections.
In HKLM\system\state\Hardware
you can find the current power state of the various devices.
Use HttpWebRequest
, and try connecting to Google:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest(v=VS.80).aspx
精彩评论