I've currently implemented this demo code for an APP sucessfully, http://www.jasontpenny.com/blog/2010/03/23/custom-protocol-handler-in-delphi/, However it seems to only work if the application is a single form application.
What I have found is that no Factory is returned for CoGetClassObject in:
procedure NewProtocolHandler(const aProtocolName: String; aProtocolCallback: TProtocolCallback; aProtocollType: TGUID);
var
error : HRESULT;
begin
if _protocol <> '' then
raise Exception.Create('Currently only supports a single asynchronous pluggable protocol');
_protocol := aProtocolName;
_protocolCallback := aProtocolCallback;
error := CoGetClassObject(Class_AsyncPlugProto_Protocol, CLSCTX_SERVER, nil, IClassFactory, Factory);
CoInternetGetSession(0, InternetSession, 0);
InternetSession.RegisterNameSpace(Factory, Class_AsyncPlugProto_Protocol, PChar(_protocol), 0, nil, 0);
CoCreateInstance(aProtocollType, nil {was IUnknown(Self)}, CLSCTX_INPROC_SERVER, IUnknown, MyProtocol);
end;
and I've come to believe that this is due to an incorrect ComServer in the initialization section.
initialization
TComObjectFactory.Create(ComServer, TAsyncPlugProto, Class_AsyncPlugProto_Protocol, 'Protocol', '', ciMultiInstance, tmApartment);
finalization
EndProtocolHandler;
end.
My web browser is not actually part of a form as I've allowed for multiple browsers to be used in my application, so the Browser is declared as a TWinControl and if the conditions are meet for a TWebBrowser its created through :
FBrowser := TWebBrowser.Create(nil);
and accessed as:
(FBrowser as TWebBrowser)
I'm fairly new to Com functions so how can I go about finding the ComServer relative to the TWebBrowser?