OnGetOptionKeyPath
GetOptionKeyPath is a powerful function that will
allow you to specify the registry location for your
webbrowser-application's preference settings. The path you set in
this function will always be a subkey under HKEY_CURRENT_USER. If
the function returns S_FALSE (default in EmbeddedWb), your
Webbrowser-application will use the default settings in
HKEY_CURRENT_USER\Sofware\Microsoft\Internet
Explorer.
This means that the following two examples are identical:
function
TForm1.EmbeddedWB1GetOptionKeyPath(var pchKey: PWideChar;
const dw: Cardinal): HRESULT;
begin
pchKey:='Software\Microsoft\Internet Explorer';
Result:=S_OK;
end;
|
function
TForm1.EmbeddedWB1GetOptionKeyPath(var pchKey: PWideChar;
const dw: Cardinal): HRESULT;
begin
Result:=S_FALSE;
end;
|
pchKey is the path for your preference settings.
Remember to omit the leading '\' in the path. The constant dw
is not used.
To take full advance of this useful function, you should open
your Registry Editor and study the settings under HKEY_CURRENT_USER\Sofware\Microsoft\Internet
Explorer. Since this function is called just before OnDownloadBegin,
you can even use it to set up different settings for different
web-locations.
In the following stupid demo we use OnGetOptionKeyPath to
add an extra item to the default extended menu (mouse right-click
menu) when - and only when - the webbrowser loads www.borland.com
:
Add to the registry under HKEY_CURRENT_USER
New key: Software\OurSetting\Internet
Explorer.
New key: Software\OurSettings\Internet Explorer\MenuExt.
New key: Software\OurSettings\Internet Explorer\MenuExt\Home Sweet
Home\.
add Binary Value 'Contexts' = 01
function
TForm1.EmbeddedWB1GetOptionKeyPath(var pchKey: PWideChar;
const dw: Cardinal): HRESULT;
begin
if Pos('www.borland.com',
lowercase(embeddedwb1.LocationUrl)) > 0 then
begin
pchKey := 'Software\OurSettings\Internet
Explorer'
Result:=S_OK;
end else
Result:=S_FALSE;
end;
|
HINT:
Use a registry monitor tool and follow how your
webbrowser-application uses the registry. A nice tool called Regmon95
is available from www.sysinternals.com,
and it's free!