유돌이

calendar

1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

Notice

2009. 5. 26. 20:24 델파이

uses
 
ActiveX, Shdocvw_tlb, MSHTML_TLB;

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;

 

 

[※ 참고]

: 프레임의 경우엔 프레임의 인터페이스를 얻는 방법과 Shell Embedding 이란 클래스 핸들을 얻어서 다시 Shell DocObject View 클래스 핸들을 얻고, 다시 Internet Explorer_Server 핸들을 얻으면 됩니다. 그러니까 프레임은 Shell Embedding 클래스 안에 Shell DocObject View가 여러개 있는게 되죠...^^;

 

 

 

 

출처 : http://skyrack.tistory.com/45#recentTrackback 

사진찍는 나귀

posted by 유돌이