개발자의 노트
반응형

 

type

TObjectFromLResult = function(LRESULT: lResult; const IID: TIID;

WPARAM: wParam; out pObject): HRESULT; stdcall;


function GetIEFromHWND(WHandle: HWND; var IE: IWebbrowser2): HRESULT;

var

hInst: HWND;

lRes: Cardinal;

MSG: Integer;

pDoc: IHTMLDocument2;

ObjectFromLresult: TObjectFromLresult;

begin

hInst := LoadLibrary(‘Oleacc.dll’);

@ObjectFromLresult := GetProcAddress(hInst, ‘ObjectFromLresult’);

if @ObjectFromLresult <> nil then

begin

try

MSG := RegisterWindowMessage(‘WM_HTML_GETOBJECT’);

SendMessageTimeOut(WHandle, MSG, 0, 0, SMTO_ABORTIFHUNG, 1000, lRes);

Result := ObjectFromLresult(lRes, IHTMLDocument2, 0, pDoc);

if Result = S_OK then

(pDoc.parentWindow as IServiceprovider).QueryService(IWebbrowserApp, IWebbrowser2, IE);

finally

FreeLibrary(hInst);

end;

end;

end;

profile

개발자의 노트

@곽코딩

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!