var pfObjectFromLresult :TObjectFromLresult; spDoc :IHTMLDocument2; hInst :HWND; nMsg :Integer; lRes :Cardinal; hr :HRESULT; spStream :IStream; hHTMLText :HGLOBAL; spPSI :IPersistStreamInit; begin CoInitialize( nil ); hInst := LoadLibrary('Oleacc.dll'); @pfObjectFromLresult := GetProcAddress(hInst, 'ObjectFromLresult'); if @pfObjectFromLresult <> nil then begin nMsg := RegisterWindowMessage('WM_HTML_GETOBJECT'); end; if ( hInst<>0 ) then begin if ( hWndChild<>0 ) then begin SendMessageTimeout( hWndChild, nMsg, 0, 0, SMTO_ABORTIFHUNG, 1000, lRes ); if ( @pfObjectFromLresult<>nil ) then begin if (spDoc<>nil) then spDoc._Release(); hr := pfObjectFromLresult(lRes, IID_IHTMLDocument2, 0, spDoc); if ( SUCCEEDED(hr) ) then begin if (spDoc<>nil) then begin hHTMLText := GlobalAlloc(GPTR, Length(HTMLCode) + 1); if 0 = hHTMLText then RaiseLastWin32Error; CopyMemory( Pointer(hHTMLText), PChar(HTMLCode), Length(HTMLCode) ); hr := CreateStreamOnHGlobal(hHTMLText, True, spStream) ; if (SUCCEEDED(hr)) then begin hr := spDoc.QueryInterface(IPersistStreamInit, spPSI); if (SUCCEEDED(hr) and (spPSI<>nil)) then begin try try try OleCheck(spPSI.InitNew); OleCheck(spPSI.Load(spStream)); spDoc.close(); Except On E:Exception Do ShowMessage(E.Message); end; finally spPSI := nil; end; finally spStream := nil; end; end; end; end; end; end; end; // else document not ready end; if (hInst<>0) then FreeLibrary( hInst ); CoUninitialize(); if (spDoc<>nil) then spDoc := nil; end;