hello guys
iam trying to add a url check to an dll but i think there's smth wrong
here's my codeany one can help in that ? :)
iam trying to add a url check to an dll but i think there's smth wrong
here's my code
Code
#include <iostream>
#include <windows.h>
#include <wininet.h>
#pragma comment(lib,"Wininet.lib")
bool URLExists(char *pUrl)
{
HINTERNET hInternet = InternetOpen("ValidURL", INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0);
bool bValid = false;
if (hInternet)
{
HINTERNET hFile = InternetOpenUrl(hInternet, pUrl, 0, 0, INTERNET_FLAG_RELOAD, 0);
if (hFile)
{
int code = 0;
DWORD length = sizeof(int);
HttpQueryInfo(hFile, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &code, &length, 0);
bValid = code == HTTP_STATUS_OK || code == HTTP_STATUS_REDIRECT;
InternetCloseHandle(hFile);
}
InternetCloseHandle(hInternet);
}
return bValid;
}
int main()
{
if (URLExists("the url "))
std::cout << "URL Exist" << std::endl;
else
std::cout << "URL Not Exist" << std::endl;
system("PAUSE");
return 0;
}

