以上是代码是今天一个网站上看到的,这个错误自己也曾经犯过这个错误,所以把它帖了过来,作为警示。
#include "stdafx.h"
#include <windows.h>
#include <tchar.h>
#include <wininet.h>
#include <urlmon.h>
#include <mshtml.h>
int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr;
CComPtr<IHTMLDocument2> document;
hr = CoInitialize(0);
if (FAILED(hr))
{
exit(hr);
}
hr = document.CoCreateInstance(CLSID_HTMLDocument);
if (FAILED(hr))
{
exit(hr);
}
CoUninitialize();
return 0;
}