WebBrowserDemo

win8.1下

RECT rc;
	IWebBrowser2* iWebBrowser;
	VARIANT varMyURL;
	static CAxWindow WinContainer;
	LPOLESTR pszName=OLESTR("shell.Explorer.2");
	GetClientRect(hWnd, &rc);
TCHAR cFilePath[MAX_PATH] = {0};
			TCHAR cAppFileName[MAX_PATH] = {0};
			GetModuleFileName(0, cAppFileName, MAX_PATH);
			TCHAR* p = wcsrchr(cAppFileName, '\\');
			*p = 0;
			swprintf_s(cFilePath, _T("%s\\License.html"), cAppFileName);

			WinContainer.Create(hWnd, &rc, 0,WS_CHILD |WS_VISIBLE);
			WinContainer.CreateControl(pszName);
			WinContainer.QueryControl(__uuidof(IWebBrowser2),(void**)&iWebBrowser); 
			VariantInit(&varMyURL);
			varMyURL.vt = VT_BSTR; 
			//varMyURL.bstrVal = SysAllocString(_T("http://www.baidu.com"));
			varMyURL.bstrVal = SysAllocString(cFilePath);
			iWebBrowser-> Navigate2(&varMyURL,0,0,0,0);
			VariantClear(&varMyURL); 
			iWebBrowser-> Release();

 

你可能感兴趣的:(WebBrowser)