如何找到用于TWebBrowser异步可插入协议的ComServer [英] How can I find the ComServer for a TWebBrowser Asynchronous Pluggable Protocol

查看:41
本文介绍了如何找到用于TWebBrowser异步可插入协议的ComServer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前已成功为APP实现了此演示代码, http://www.jasontpenny.com/blog/2010/03/23/custom-protocol-handler-in-delphi/,但是,似乎只有在应用程序为单一表格申请.

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.

我发现在以下情况下,没有为CoGetClassObject返回工厂:

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;

并且我已经开始相信这是由于初始化部分中的ComServer错误所致.

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. 

我的网络浏览器实际上不是表单的一部分,因为我允许在应用程序中使用多个浏览器,因此该浏览器被声明为TWinControl,并且如果满足条件,则可以通过以下方式创建TWebBrowser:/p>

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);

并以以下方式访问:

(FBrowser as TWebBrowser)

我对Com函数还很陌生,那么如何找到相对于TWebBrowser的ComServer?

I'm fairly new to Com functions so how can I go about finding the ComServer relative to the TWebBrowser?

推荐答案

我认为您在混淆很多事情.如果您想制作一个APP,则可以通过几种方式对COM对象进行一些工作.

I think you're confusing a number of things. If you'd like to make an APP, it would help if you've done some work with COM objects in several ways.

ComServer对象实际上是一个中心对象,如果有COM内部组件,这些对象将被包裹起来,以备在Delphi项目中使用.由于Internet Explorer不是Delphi项目,因此您将无法获得其ComServer .另外,如果仔细看一下TWebBrowser对象,您会注意到它也是IWebBrowser2对象的COM内部的包装.

The ComServer object is actually a central object that wraps around some if the COM internals, ready for use in a Delphi project. Since Internet Explorer is not a Delphi project you won't be able to get its ComServer. Also if you have a close look at the TWebBrowser object, you'll notice that it also is a wrapper around the COM internals of the IWebBrowser2 object.

TWebBrowser和TChromium是两个单独的项目. As 是很好的运算符,但是它无法将任何内容更改为您想要的任何内容.

TWebBrowser and TChromium are two separate projects. As is a great operator but it can't change something to whichever you want.

如果您想要APP的另一个示例,请在这里查看: http://xxm.svn.sourceforge.net/viewvc/xxm/trunk/Delphi/local/xxmHandler.pas?revision = 235& view = markup

If you want another example of an APP have a look here: http://xxm.svn.sourceforge.net/viewvc/xxm/trunk/Delphi/local/xxmHandler.pas?revision=235&view=markup

这篇关于如何找到用于TWebBrowser异步可插入协议的ComServer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆