今天用到了,从网上搜了个方法,关键代码如下:
#include <OleAcc.h>
#pragma comment(lib, "OleAcc.lib")
//hWnd:Internet Explorer_Server
LRESULT lResult = 0;
UINT uMessage = ::RegisterWindowMessage(_T("WM_HTML_GETOBJECT"));
::SendMessageTimeout(hWnd, uMessage, 0, 0, SMTO_ABORTIFHUNG, 1000, (DWORD*)&lResult);
CComQIPtr<IHTMLDocument> pDoc;
::ObjectFromLresult(lResult, IID_IHTMLDocument, 0, (void**)&pDoc);