主要使用IWebBrowser接口。具体可参考如下博文:http://blog.csdn.net/shanhe/article/details/397373
代码如下:
#include <Windows.h> #include <ExDisp.h> #include <assert.h> #include <iostream> using namespace std; int main() { HRESULT hr; IWebBrowser2 *pWebBrowser2 = NULL; OleInitialize(NULL); hr = CoCreateInstance(CLSID_InternetExplorer,NULL, CLSCTX_LOCAL_SERVER, IID_IWebBrowser2, (void**)&pWebBrowser2); assert(SUCCEEDED(hr)); VARIANT vEmpty; VariantInit(&vEmpty); BSTR bstrURL = SysAllocString(L"http://www.baidu.cn"); hr = pWebBrowser2->Navigate(bstrURL, &vEmpty, &vEmpty, &vEmpty, &vEmpty); if (SUCCEEDED(hr)) { pWebBrowser2->put_Visible(VARIANT_TRUE); //pWebBrowser2->put_FullScreen(VARIANT_TRUE); //pWebBrowser2->put_Width(200); Sleep(3000); pWebBrowser2->Refresh(); pWebBrowser2->GoHome(); } else { pWebBrowser2->Quit(); } SysFreeString(bstrURL); pWebBrowser2->Release(); OleUninitialize(); return 0; }