Visual C ++ 2013调试断言在atlcomcli.h运行时失败p!= 0

时间:2015-03-12 03:13:13

标签: c++ pointers com assertion

我正在尝试创建IXMLHTTPREQUEST的智能指针,并让它打开到示例URL的http连接。添加了一些打印行以找到失败的位置。

    static const TCHAR* const g_lpszSOAPEndpointURL =
        _T("http://www.webservicex.net/country.asmx?op=GetCurrencyByCountry");
    USES_CONVERSION;

    printf("Hello 2 \n");
    CComPtr<IXMLHTTPRequest> spXMLHTTP = NULL;
    printf("Hello 3A...\n");

    HRESULT hr = spXMLHTTP.CoCreateInstance(__uuidof(IXMLHttpRequest));
    if (S_OK != hr)
        printf("Hello 3...\n");
    else 
        printf("Pointer creation failed..");

//  Initialize the Synchronous HTTP POST request
    spXMLHTTP->open(BSTR("POST"), BSTR(g_lpszSOAPEndpointURL), 
            _variant_t(VARIANT_FALSE), _variant_t(""), _variant_t(""));
    printf("Hello 4...\n");
    printf("Hello 5...\n");

输出在“Hello 3...”之后停止,并抛出atlcomcli运行时错误。

0 个答案:

没有答案