Hi, there is in C something I can do if I want to see if I'm online ?
Thanx
Hi, there is in C something I can do if I want to see if I'm online ?
Thanx
This forum is the best one I've ever seen. Great ppl, great coders
Find out how to do network connections in C (I think you'd have to have an extra library for this - unless there's a way to route stdin/out through a modem), and then treat it like finding out if opening a file worked. Open a file and then use an if statement on the result of that file. If it returns true - you're connected. If it returns false, you're not.
"Usually the best way to determine if you have a connection to a particular computer is to attempt the connection."
Q242558: How To Detecting(sic) If You Have a Connection to the Internet
a quick help :
I link Wininet.lib too....... and I get this :Code:#include <stdio.h> #include <stdlib.h> #include <wininet.h> int main() { if (InternetGetConnectedState(INTERNET_CONNECTION_OFFLINE,0) == FALSE) prinft("1"); else printf("2"); system("PAUSE"); return 0; }
8 main.c `INTERNET_CONNECTION_OFFLINE' undeclared (first use in this function)
why ??
ps( in the code (INTERNET_CONNECTION_OFFLINE,0) it is bad written but it the forum, not my code)
This forum is the best one I've ever seen. Great ppl, great coders
The first argument to the function takes the address of a DWORD that will return additional information.
You may need to update your header/library files.Code:int main(void) { DWORD dwState; if (InternetGetConnectedState(&dwState, 0) == FALSE) { printf("1"); } else { printf("2"); } system("PAUSE"); return 0; }
ahhhhhhhh now i got it !!!
thanx
This forum is the best one I've ever seen. Great ppl, great coders