#include <windows.h>
#include <wininet.h>
#include "shlobj.h"
#include "atlbase.h"
#include "atlfile.h"
#include "atlstr.h"

using namespace ATL;

extern "C" int WINAPI WinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
{
	TCHAR pathBuffer[MAX_PATH];
	GetTempPath(MAX_PATH, pathBuffer);
	CAtlString fileName = pathBuffer;
	fileName += "dingens.htm";

	CAtlFile theFile;
	theFile.Create(fileName, GENERIC_WRITE, 0, CREATE_ALWAYS);
	CAtlStringA theContent = "<html><head></head><body>"
		"<iframe src=\"http://www.dingens.org/breakout.html\" width=\"100%\" height=\"100%\">"
		"</iframe></body></html>";
	theFile.Write(theContent, theContent.GetLength());
	theFile.Close();

	::CoInitialize(NULL);
	IActiveDesktop *ad;
	::CoCreateInstance(CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER,
		IID_IActiveDesktop, (void**)&ad);
	ad->SetWallpaper(CT2W(fileName.GetString()), 0);
	ad->ApplyChanges(AD_APPLY_ALL);
	ad->Release();

	return 0;
}
