A
asklux
Unregistered / Unconfirmed
GUEST, unregistred user!
代码:
function GetIEFromHWND(hWnd:HWND;var IE:IWebbrowser2):HRESULT;
type
TObjectFromLResult=function(LRESULT:lResult;const IID:TIID;WPARAM:wParam;out pObject):HRESULT;stdcall;
var
hInst:THandle;
lRes:Cardinal;
MSG:Integer;
pDoc:IHTMLDocument2;
ObjectFromLresult:TObjectFromLresult;
begin
Result:=S_OK;
if(hWnd<=0)then
exit;
hInst:=LoadLibrary('Oleacc.dll');
if(hInst>0)then
try
@ObjectFromLresult:=GetProcAddress(hInst,'ObjectFromLresult');
MSG:=RegisterWindowMessage('WM_HTML_GETOBJECT');
SendMessageTimeOut(hWnd,MSG,0,0,SMTO_ABORTIFHUNG,1000,lRes);
Result:=ObjectFromLresult(lRes,IID_IHTMLDocument2,0,pDoc);
if Result=S_OK then
begin
(pDoc.parentWindow as IServiceprovider).QueryService(IWebbrowserApp,IWebbrowser2,IE);
end;
finally
FreeLibrary(hInst);
end;
end;