C# Programming
04-01-2009, 04:40 PM
Hi! I' m using this sample to check if the machine is connected to Internet, but it gives me 3 errors. Why' s that?
Here is the sample:
using System;
using System.Runtime;
using System.Runtime.InteropServices;
class IsConnected
{
//Creating the extern function...
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState(int out Description, int ReservedValue);
//Creating a function that uses the API function...
public static bool IsConnectedToInternet()
{
int Desc;
return InternetGetConnectedState(out Desc, 0);
}
}
Here are the errors:
Error 1: Identifier expected; 'out' is a keyword | Line: 9
Error 2: Invalid token ',' in class, struct, or interface member declaration | Line: 9
Error 3: ; expected | Line: 9
"Good artists copy, great artists steal."
Here is the sample:
using System;
using System.Runtime;
using System.Runtime.InteropServices;
class IsConnected
{
//Creating the extern function...
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState(int out Description, int ReservedValue);
//Creating a function that uses the API function...
public static bool IsConnectedToInternet()
{
int Desc;
return InternetGetConnectedState(out Desc, 0);
}
}
Here are the errors:
Error 1: Identifier expected; 'out' is a keyword | Line: 9
Error 2: Invalid token ',' in class, struct, or interface member declaration | Line: 9
Error 3: ; expected | Line: 9
"Good artists copy, great artists steal."