Detecting which network adapter is in use

  • Thread starter Thread starter Rob Peppin
  • Start date Start date
R

Rob Peppin

I have been developing a messaging system for PocketPC
2003 using c# and I would like to be able to detect what
kind of conncetion I have got (LAN, WIFI, GPRS etc..) so
that I don't send too much data down a costly connection
(GPRS can get costly!!!)

Does anyone know of anyway of getting this kind of
information from the device as I don't think the compact
framework supports this kind of request.

The only way I can do this at the moment is to examine the
transfer rates I am getting and based on this I can infer
what kind of conncetion I have, but it isn't nice!
 
Well, you can use GetAdaptersInfo() to get the adapter types. I think
you're going to have to hook into NDISUIO to actually tell when a given
adapter is 'connected'. Neither of those things is directly supported in
..NET CF and the NDISUIO thing will pretty much require C, although I guess
you could poll from C#/VB.NET. Some of this has been covered from the C
perspective in the Windows CE newsgroups, so you might check there for more
details:

http://groups.google.com/groups?hl=en&group=microsoft.public.windowsce

One other thing to note is that you can't tell from any piece of information
which 'adapter is in use'. The routing code in the TCP/IP stack determines
that on its own and it might switch from one to another to another behind
your back, unless you establish static routes.

Paul T.
 
Back
Top