用 Delphi 7 创建 ActiveX 组件交 ASP 使用
2009-04-06 15:25
471 查看
用 Delphi 7 创建 ActiveX 组件交 ASP 使用
一、启动 Delphi 7 ,新建 ActiveX - ActiveX Library ;
二、引入类库先,若你的 Delphi 还没有引入 asp 组件的话。
Project - Import Type Library ,“Microsoft Active Server Pages Object Library(Version 3.0)”,对应的dll文件是:“系统盘:/Windows目录/system32/inetsrv/asp.dll”,为防止组件名称重复,将TRequest,TResponse,TSession 分别重命名为 TAspRequest,TAspResponse,TAspSession,再点击“Install...”。
三、新建 ActiveX - Automation Object ,coClassName ="test2",Instancing="Multiple Instance";
四、在"Itest2"上新建方法:
1、OnStartPage,参数:const unk:IUnknown,
2、OnEndPage
3、Test(测试方法)
五、代码:
六、注册ActiveX组件:
regsvr32 Project1.dll
反注册是:regsvr32 /u Project1.dll
注:若Delphi需重新编译工程,而IIS又在用这个dll,则重启w3c服务才能断开iis与dll的连接,才能编译。
七、ASP使用:
一、启动 Delphi 7 ,新建 ActiveX - ActiveX Library ;
二、引入类库先,若你的 Delphi 还没有引入 asp 组件的话。
Project - Import Type Library ,“Microsoft Active Server Pages Object Library(Version 3.0)”,对应的dll文件是:“系统盘:/Windows目录/system32/inetsrv/asp.dll”,为防止组件名称重复,将TRequest,TResponse,TSession 分别重命名为 TAspRequest,TAspResponse,TAspSession,再点击“Install...”。
三、新建 ActiveX - Automation Object ,coClassName ="test2",Instancing="Multiple Instance";
四、在"Itest2"上新建方法:
1、OnStartPage,参数:const unk:IUnknown,
2、OnEndPage
3、Test(测试方法)
五、代码:
unit Unit1; {$WARN SYMBOL_PLATFORM OFF} interface uses ComObj, ActiveX, Project1_TLB, StdVcl,ASPTypeLibrary_TLB; //1 type TTestObject = class(TAutoObject, ITestObject) protected procedure OnStartPage(const unk: IUnknown); safecall; procedure OnEndPage; safecall; procedure test; safecall; end; implementation uses ComServ; var m_scriptContext:IScriptingContext; //2 procedure TTestObject.OnStartPage(const unk: IUnknown); begin m_scriptContext:=unk as IScriptingContext; //3 end; procedure TTestObject.OnEndPage; begin m_scriptContext:=nil; //4 end; //5 procedure TTestObject.test; begin m_scriptContext.Response.Write('ActiveX test for Delphi'); m_scriptContext.Response.Write('大家好,我是由Delphi创建的ActiveX组件的输出信息.'); end; initialization TAutoObjectFactory.Create(ComServer, TTestObject, Class_TestObject, ciMultiInstance, tmApartment); end.
六、注册ActiveX组件:
regsvr32 Project1.dll
反注册是:regsvr32 /u Project1.dll
注:若Delphi需重新编译工程,而IIS又在用这个dll,则重启w3c服务才能断开iis与dll的连接,才能编译。
七、ASP使用:
<div> <% Dim obj Set obj=Server.CreateObject("Project1.TestObject") obj.test Set obj=nothing %> </div>
相关文章推荐
- 用 Delphi 7 创建 ActiveX 组件交 ASP 使用
- 手把手教你使用VB来创建ASP组件
- ActiveX部件不能创建对象“server.createobject("")” 用到的asp组件是第三方,
- 手把手教你使用VB来创建ASP组件
- 手把手教你使用VB来创建ASP组件
- 用delphi编写asp使用的组件
- 手把手教你使用VB来创建ASP组件
- Visual C#创建和使用ActiveX组件
- 关于asp使用CreateObject("Excel.Application")出现无法创建ActiveX对象的错误
- Visual C#创建和使用ActiveX组件
- 手把手教你使用VB来创建ASP组件
- Visual C#创建和使用ActiveX组件
- 手把手教你使用VB来创建ASP组件
- 手把手教你使用VB来创建ASP组件
- 使用ASP.NET页面创建可视的UI,在客户机上实例化MSXML分析器的页面从中间层组件取出XML数据、操作并显示 并有问题请高手解决
- Visual C#创建和使用ActiveX组件
- C#创建和使用ActiveX组件
- ASP.NET_Ajax实训练习之创建和使用Ajax组件
- 手把手教你使用VB来创建ASP组件
- 手把手教你使用VB来创建ASP组件