int main()
{
CoInitialize(NULL);
HRESULT hr;
IWinHttpRequestPtr pHttpReq=NULL;
pHttpReq.CreateInstance(__uuidof(WinHttpRequest));
CoUninitialize();
}
上面的代码在win32工程中会崩溃的。
解决办法1:
int main()
{
CoInitialize(NULL);
{
HRESULT hr;
IWinHttpRequestPtr pHttpReq=NULL;
pHttpReq.CreateInstance(__uuidof(WinHttpRequest));
}
CoUninitialize();
return 0;
解决办法2:
int main()
{
CoInitialize(NULL);
HRESULT hr;
IWinHttpRequestPtr pHttpReq=NULL;
pHttpReq.CreateInstance(__uuidof(WinHttpRequest));
pHttpReq=NULL;
CoUninitialize();
return 0;
}