HTTP GET在使用IXMLHTTPRequest2的Metro C ++应用程序中不起作用 [英] HTTP GET not working in Metro C++ app using IXMLHTTPRequest2
问题描述
在Metro C ++应用程序中使用IXMLHTTPRequest2时,我遇到任何类型的响应或错误。 这就是我正在做的事情(出于空间原因省略了错误处理):
I am having trouble getting any sort of response or error when using IXMLHTTPRequest2 in our Metro C++ application. This is what I'm doing (error handling omitted for space reasons):
HRESULT hr;
DWORD dwStatus = 0;
ComPtr<IXMLHTTPRequest2> xhr;
ComPtr<CXMLHttpRequest2Callback> xhrMyCallback;
ComPtr<IXMLHTTPRequest2Callback> xhrCallback;
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
hr = CoCreateInstance(CLSID_FreeThreadedXMLHTTP60, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&xhr));
hr = MakeAndInitialize<CXMLHttpRequest2Callback>(&xhrMyCallback);
hr = xhrMyCallback.As(&xhrCallback);
hr = xhr->Open(L"GET", L"http://www.google.com", xhrCallback.Get(), NULL, NULL, NULL, NULL);
hr = xhr->Send(NULL, 0);
hr = xhrMyCallback->WaitForComplete(&dwStatus);
对于 CXMLHttpRequest2Callback,我正在使用此示例中的代码: XML
HTTP请求2 GET示例
For the CXMLHttpRequest2Callback, I'm using the code from this example: XML HTTP Request 2 GET sample
调用WaitForComplete之后( ),回调永远不会收到OnError()或OnResponseReceived()事件。 我已在清单文件中启用了"Internet客户端"权限。
After calling WaitForComplete(), the callback never receives the OnError() or OnResponseReceived() events. I have enabled the 'Internet Client' permission in the manifest file.
我在猜什么?
谢谢!
推荐答案
尝试在等待中添加消息泵。
try add a message pump to the wait.
这篇关于HTTP GET在使用IXMLHTTPRequest2的Metro C ++应用程序中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!