What's wrong with this code, Part 18
This may be the shortest "Bad Code" I've ever done, but it keeps on surprising me how many times I see this problem (people asked me questions about it twice in the past week).
// BadCode18.cpp : Defines the entry point for the console application.
//
#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;
}
That's all it takes, I consciously chose not to add stuff to obfuscate the problem.
Btw, for those who've been reading this blog for a while, I covered this exact same issue in a different form a while ago.