0

我在这里附上了我的代码我不知道为什么我会收到错误,12005尽管 URL 是正确的。我不能透露我的网址。请帮我解决一下这个。尝试添加一些其他 URL 并检查其是否有效。

#include "stdafx.h"
#include "conio.h"
#include "Windows.h"
#include "WinInet.h"
int main()
{
    HINTERNET connect = InternetOpen(L"MyBrowser",0 ,0, 0, 0);
    if (!connect)
    {
       printf("Connection Failed or Syntax error");
       return 0;
    }

HINTERNET OpenAddress = InternetConnect(connect, L"https://mydomain.com", INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, INTERNET_SERVICE_HTTP,0,0);
    if (!OpenAddress)
    {
        DWORD ErrorNum = GetLastError();
        printf("Failed to open URL" );//<< endl << " Error No: "  ErrorNum;
        InternetCloseHandle(connect);
        return 0;
    }
    else
    {
        printf("Opened Successfully");
    }

    HINTERNET hHttpRequest = HttpOpenRequest(OpenAddress, L"POST", L"name=name&age=age&height=height", 0, 0, 0, INTERNET_FLAG_RELOAD, 0);

    if(!HttpSendRequest(hHttpRequest, NULL,0, NULL, 0)) 
    {
        DWORD dwErr = GetLastError();
        printf("\nError");
        printf("%d",dwErr); 
    }

    InternetCloseHandle(connect);
    InternetCloseHandle(OpenAddress);
    InternetCloseHandle(hHttpRequest);
    return 0;
}
4

0 回答 0