HTTP GET在使用IXMLHTTPRequest2的Metro C ++应用程序中不起作用 [英] HTTP GET not working in Metro C++ app using IXMLHTTPRequest2

查看:45
本文介绍了HTTP GET在使用IXMLHTTPRequest2的Metro C ++应用程序中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆