Here, i will add some sample codes that are needed for programmers or software developers.
For example is how to learn that your computer is connected to the internet by the help of some simple c# codes. :p
firstly, you must add the wininet.dll.
to do this, you can write the following code and then define a function that is related to the internet connection state.
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState(out int Description, int ReservedValue);
after that, you write a function that calls the above function and returns a boolean value.
public static bool IsConnectedToInternet()
{
int Desc;
return InternetGetConnectedState(out Desc, 0);
}
if it is true, that means you are connected to the internet, if it is not, i am sorry that you are not connected to the internet.
i forgot to tell you that you must add some libraries into your code.
using System.Runtime;
using System.Runtime.InteropServices;
i will add small code samples soon.

Leave a comment
Comments feed for this article