Visual c++ VC+中的Http Post+;

Visual c++ VC+中的Http Post+;,visual-c++,wininet,Visual C++,Wininet,我已经在这里附加了我的代码,我不知道为什么会出现错误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 (!conne

我已经在这里附加了我的代码,我不知道为什么会出现错误
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;
}
#包括“stdafx.h”
#包括“conio.h”
#包括“Windows.h”
#包括“WinInet.h”
int main()
{
HINTERNET connect=InternetOpen(L“MyBrowser”,0,0,0);
如果(!连接)
{
printf(“连接失败或语法错误”);
返回0;
}
HINTERNET OpenAddress=互联网连接(连接,L“https://mydomain.com“,INTERNET\u默认\u HTTPS\u端口,NULL,NULL,INTERNET\u服务\u HTTP,0,0);
如果(!OpenAddress)
{
DWORD ErrorNum=GetLastError();

printf(“无法打开URL”);//从
InternetConnect
的文档判断,第二个参数似乎只是主机名,而不是URI(端口和服务是其他参数,因此我认为它不会从URI派生该信息)。此外,您的
HttpOpenRequest
调用可能需要一个前导“/?”对于
lpszObjectName
参数(注意:绝对纯猜测)。