uses
ActiveX, ComObj;
procedure WB_PrintWithHeaderFooter(Webbrowser: TWebbrowser; Header, Footer: PWideChar);
var
saBound: TSafeArrayBound;
psaHeadFoot: PSafeArray;
vaIn, vaOut: TVariantArg;
vHeadStr, vFootStr: TVariantArg;
rgIndex: LongInt;
begin
try
saBound.lLbound := 0;
saBound.cElements := 2;
psaHeadFoot := SafeArrayCreate(VT_VARIANT, 1, saBound);
vHeadStr.vt := VT_BSTR;
vHeadStr.bstrVal := SysAllocString(Header);
vFootStr.vt := VT_BSTR;
vFootStr.bstrVal := SysAllocString(Footer);
rgIndex := 0;
OleCheck(SafeArrayPutElement(psaHeadFoot, rgIndex, vHeadStr));
rgIndex := 1;
OleCheck(SafeArrayPutElement(psaHeadFoot, rgIndex, vFootStr));
vaIn.vt := VT_ARRAY
or VT_BYREF;
vaIn.parray := psaHeadFoot;
Webbrowser.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER,
OleVariant(vaIn), OleVariant(vaOut));
if vHeadStr.bstrVal <>
nil then
SysFreeString(vHeadStr.bstrVal);
if vFootStr.bstrVal <>
nil then
SysFreeString(vFootStr.bstrVal);
except
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
WB_PrintWithHeaderFooter(Webbrowser, '
', '
');
// Kein Header & Footer
end;