uses
ActiveX, MSHTML;
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
Result := S_FALSE;
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;
function SetWBSilent(hIE: HWND) :
string;
// wnd: 'Internet Explorer_Server' Klasse
var
IE: IWebBrowser2;
begin
if hIE <> 0
then
begin
if GetIEFromHWnd(hIE, IE) = S_OK
then
if IE <>
nil then
IE.Silent := True;
end;
end;