BOOL CheckServerStatus::isConnectServer(CString serverName, int serverPort)
{
CString strURL;
strURL.Format("http://%s:%d", serverName, serverPort);
BOOL hSession = GetSession(strURL);
return hSession;
}
BOOL CheckServerStatus::GetSession(CString URL)
{
HINTERNET hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL);
if (NULL == hInternet)
{
InternetCloseHandle(hInternet);
return FALSE;
}
DWORD options = INTERNET_FLAG_NEED_FILE | INTERNET_FLAG_HYPERLINK | INTERNET_FLAG_RESYNCHRONIZE | INTERNET_FLAG_RELOAD;
HINTERNET hInternetUrl = InternetOpenUrl(hInternet, URL, NULL, NULL, options, NULL);
if (NULL == hInternetUrl)
{
return FALSE;
}
InternetCloseHandle(hInternet);
InternetCloseHandle(hInternetUrl);
return TRUE;
}