#include <Ole2.h> #include <ExDisp.h> #include <iostream> class __declspec(uuid("{D30C1661-CDAF-11D0-8A3E-00C04FC9E26E}")) riid; // IWebBrowser2 class __declspec(uuid("{0002DF01-0000-0000-C000-000000000046}")) clsid; // IE INT testCOM(VOID) { OutputDebugString(L"Begin\r\n"); OleInitialize(NULL); const CLSID cClsidIE = __uuidof(clsid); const IID cIidIWebBrowser2 = __uuidof(riid); LPVOID pFunc = 0; HRESULT hRes = CoCreateInstance(cClsidIE, NULL, CLSCTX::CLSCTX_LOCAL_SERVER, cIidIWebBrowser2, &pFunc); if (hRes != S_OK) { OutputDebugString(L"[Fail]CoCreateInstance\r\n"); //return 0; } IWebBrowser2 *pBrowser = static_cast<IWebBrowser2 *>(pFunc); if (pBrowser) { VARIANT tmp; BSTR URL = SysAllocString(L"baidu.com"); OutputDebugString(L"[DBG]pBrowser\r\n"); pBrowser->Navigate(URL, &tmp, &tmp, &tmp, &tmp); SysFreeString(URL); hRes = pBrowser->put_Visible(VARIANT_TRUE); pBrowser->Release(); } CoUninitialize(); OutputDebugString(L"End\r\n"); return 0; }
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课