NameSpaceHandler
This demo demonstrates some of the powerful features
in a temporary or permanent pluggable namespacehandler.
In a url the namespace is the "servername":
http://<NAMESPACE>/index.html
After implementing your namespacehandler you take
the control when the webbrowser-application or IE is navigating to a
URL containing the selected namespace.
You can choose between implementing a temporary
or a permanent pluggable namespacehandler.
A temporary namespacehandler is only active in the
application where it is registered. At any time you can
unregister the NS-handler. There is no DLL-files or writing to
registry. If you want to use temporary pluggable namespacehandler in
IE, you can implement it in a Browser Helper Object.
A permanent pluggable namespacehandler is
active for all applications and urlmonikers using the registered
protocol and namespace. Create it in a DLL and register it. Notice
the following bug report from MS:
http://support.microsoft.com/support/kb/articles/Q190/8/93.ASP
When the webbrowser-control (or IE) navigates to a
URL containing the chosen namespace, URLMON sends the URL-adress to
your namespacehandler and expects that you return some data to send
to the webbrowser. URLMON does not care what data you return or
where you get it from. The baseurl for the data you return is the
URL sent to your namespacehandler.
In the following demo we use a namespacehandler to
load webpages (including images, CSS, etc.) directly from a
paradox-database. Structured storage files could have been used, or
Wininet-functions could have been used to download data from the
internet. It is up to you how you get the data.
Use IInternetSession.RegisterNameSpace to register
the temporary pluggable namespacehandler:
procedure
TForm1.FormCreate(Sender: TObject);
begin
CoGetClassObject(Class_OurNSHandler, CLSCTX_SERVER, nil,
IClassFactory, Factory);
CoInternetGetSession(0, InternetSession, 0);
InternetSession.RegisterNameSpace(Factory, Class_OurNSHandler,
'http', 0, nil, 0);
end;
According to the documentation it should have been
possible to add namespace-patterns to RegisterNameSpace, but I have
not been able to make this work. It don't matter much in temporary
pluggable namespacehandler since we check for our namespace in
Function Start and return to default protocolhandler if the
namespace is not found in the incoming URL.
Enjoy!