현재 사용중인 PC가 인터넷에 접속되어 있는지 유무를 확인할 수 있는 방법을 알아보자.

인터넷에 접속가능한 상태를 알아보는 방법은 Wininet.DLL 에 내장된 "InternetGetConnectedState"이라는 함수를 이용하여 손쉽게 확인이 가능하다.

사용방법은 아래와 같다.

is_connect := InternetGetConnectedState(@param, 0);
If is_connect=True Then Begin
  // Internet 접속 상태
End;



BOOL InternetGetConnectedState(
  LPDWORD lpdwFlags,
  DWORD dwReserved
);

Parameters

lpdwFlags
[out] Pointer to a variable that receives the connection description. This parameter may return a valid flag even when the function returns FALSE. This parameter can be one or more of the following values.
ValueMeaning
INTERNET_CONNECTION_CONFIGURED
0x40
Local system has a valid connection to the Internet, but it might or might not be currently connected.
INTERNET_CONNECTION_LAN
0x02
Local system uses a local area network to connect to the Internet.
INTERNET_CONNECTION_MODEM
0x01
Local system uses a modem to connect to the Internet.
INTERNET_CONNECTION_MODEM_BUSY
0x08
No longer used.
INTERNET_CONNECTION_OFFLINE
0x20
Local system is in offline mode.
INTERNET_CONNECTION_PROXY
0x04
Local system uses a proxy server to connect to the Internet.
dwReserved
[in] Reserved. Must be zero.

Return Value

Returns TRUE if there is an active modem or a LAN Internet connection, or FALSE if there is no Internet connection, or if all possible Internet connections are not currently active. For more information, see the Remarks section.

When InternetGetConnectedState returns FALSE, the application can call GetLastError to retrieve the error code.

2008/07/01 10:27 2008/07/01 10:27
포스팅이 유익 하셨다면 RSS 구독을 신청하세요

Trackback Address >> http://dolba.net/tt/k2club/trackback/1870