【问题标题】:Error 12006 in WinHttpCrackUrlWinHttpCrackUrl 中的错误 12006
【发布时间】:2013-04-11 02:17:28
【问题描述】:

我正在尝试从变量构建地址。所以我可以把它传递给WinHttpOpenRequest

    char *uNameAddr = (char*) ExeBaseAddress + 0x34F01C;
    printf("%s \n", uNameAddr);

    string url = "http://xxxx.xxxx.com/xxxx/?u=";
    string username = uNameAddr;


    string combine = url + username;

    cout << combine << endl;
    //http://xxxx.xxxx.com/xxxx/?u=MyUsername <--

    URL_COMPONENTS urlComp;
    LPCWSTR pwszUrl1 = (LPCWSTR)combine.c_str();
    DWORD dwUrlLen = 0;

那我这里就得传过去了:

hRequest = WinHttpOpenRequest( hConnect, L"GET", urlComp.lpszUrlPath,
                               NULL, WINHTTP_NO_REFERER,
                               WINHTTP_DEFAULT_ACCEPT_TYPES,
                               0);

urlComp.lpszUrlPath 应该是http://xxxx.xxxx.com/xxxx/?u=MyUsername

有什么建议吗?我的应用程序在处理该部分时崩溃。


错误

 12006       ERROR_INTERNET_UNRECOGNIZED_SCHEME
             The URL scheme could not be recognized or is not supported.

【问题讨论】:

  • LPCWSTR pwszUrl1 = (LPCWSTR)combine.c_str(); 你把那个演员放在那里是为了让编译器关闭吗?愚蠢的编译器,它会知道什么。
  • 我猜。我是新手。
  • 主题说WinHttpCrackUrl,提供的代码没有。

标签: c++ dll winhttp


【解决方案1】:
LPCWSTR pwszUrl1 = (LPCWSTR)combine.c_str();

std::string::c_str 返回const char *LPCWSTR is const wchar_t *.

转换为LPCWSTR 是在欺骗编译器和你自己,combine.c_str() 返回的不是指向宽字符串的指针。

std::wstring 表示宽字符串,您可能会获得更好的成功。

考虑阅读Unicode in the Windows API了解更多信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-13
    • 2014-12-27
    • 1970-01-01
    • 2018-04-24
    • 2012-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多