Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

url exist check [c++]

hello guys
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;
}
any one can help in that ? :)
How is this a DLL to begin with? What do you think is wrong with the code?
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
dll work with online game server side included an exe prog
which it have to print the cout badly it dont
Quote: HINTERNET hInternet = InternetOpen("ValidURL", INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0);


Since you can't seem to form a question, The above useragent and open type could be giving you issues.
(Nov 15, 2014 02:21 AM)HelloMyNameIsWalter Wrote:  Since you can't seem to form a question, The above useragent and open type could be giving you issues.
thanks for help but can u explain how to reslove it ?
Quote: HINTERNET hInternet = InternetOpen("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/29.0", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0);


This may or may not fix it, Just a heads up the original code is not a dll.
well it's not fixed and how u mean it's not a dll ? :/
It's obviously not a DLL because the signature for a DLL is much different.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
(Nov 15, 2014 03:31 PM)midobahr Wrote:  well it's not fixed and how u mean it's not a dll ? :/

Why don't you read up on how to make a DLL rather than just begging for a solution. It should be obvious that this is not a DLL


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by DotexeAug 5, 2017 04:23 PM 0 154 Aug 5, 2017 04:23 PM
Last Post: Dotexe
[C#] by SwaggySwampManAug 17, 2015 08:38 AM 1 145 Aug 17, 2015 08:38 AM
Last Post: Sicarius
[.NET] by denn1sAug 16, 2015 08:28 AM 3 89 Aug 16, 2015 08:28 AM
Last Post: nathan72389