InternetGetConnectedState

M

Mark

In the following sample, INTERNET_CONNECTION_LAN returns
a value of 81:

public class Test
{

[DllImport("Wininet.dll")]
private static extern bool
InternetGetConnectedState( out int Description, int
ReservedValue ) ;
public static bool
IsConnectedToInternet( )
{

//int Desc ;
int
INTERNET_CONNECTION_LAN;
return
InternetGetConnectedState( out INTERNET_CONNECTION_LAN,
0 ) ;

}

}

What am I doing wrong to not return a BOOL value?
Thanks
Mark
 
M

Mattias Sjögren

Mark,
In the following sample, INTERNET_CONNECTION_LAN returns
a value of 81:

81 = 0x51 = INTERNET_CONNECTION_CONFIGURED |
INTERNET_RAS_INSTALLED |
INTERNET_CONNECTION_MODEM

It's somewhat confusing that you use INTERNET_CONNECTION_LAN as a
variable name, since that's the name of one of the flags that might be
returned (but isn't in this case).

What am I doing wrong to not return a BOOL value?

Not sure what you mean here. Do you get some unexpected return value?



Mattias
 
M

Mark

Hi Mattias,

Where do I find what the result for 81 equals as per:
81 = 0x51 = INTERNET_CONNECTION_CONFIGURED |
INTERNET_RAS_INSTALLED |
INTERNET_CONNECTION_MODEM

I have seen: http://msdn.microsoft.com/library/en-
us/wininet/wininet/internetgetconnectedstate.asp but
there isn't a list of possible int results which reflect
which flag or group of flags that would map to the
returned result.

How do I query the value of a specific flag that could be
returned i.e. INTERNET_CONNECTION_LAN?

Sorry if the question seems basic ... I am new to using
external DLLs within C#, and the online help at MSDN was
a little confusing :-(

Thanks
Mark
 
M

Mattias Sjögren

Mark,
Where do I find what the result for 81 equals as per:

If you have the Platform SDK installed (either separately or as part
of VC++) you can find the constant values in the Wininet.h header
file.

The command

findstr INTERNET_CONNECTION_ %mssdk%\include\wininet.h

prints

#define ERROR_INTERNET_CONNECTION_ABORTED (INTERNET_ERROR_BASE + 30)
#define ERROR_INTERNET_CONNECTION_RESET (INTERNET_ERROR_BASE + 31)
#define INTERNET_CONNECTION_MODEM 0x01
#define INTERNET_CONNECTION_LAN 0x02
#define INTERNET_CONNECTION_PROXY 0x04
#define INTERNET_CONNECTION_MODEM_BUSY 0x08 /* no longer used */
#define INTERNET_CONNECTION_OFFLINE 0x20
#define INTERNET_CONNECTION_CONFIGURED 0x40



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top