一个用delphi开发asp组件的例子
来源:互联网 发布:php codeception 编辑:程序博客网 时间:2024/06/06 12:09
打开delphi,点击菜单 File->New->Other 选择Activex->Activex Library 保存项目为HelloWorld.dpr
继续选择菜单File->New->Other 选择 Activex->Active Server Object 在CoClass Name 中添入hello
保存库文件为 helloASP.pas 保存asp文件为hello.asp
选择 Ihello节点 右击 New->Method 新建一个方法 将方法名(name)改为 test 在helloasp.pas中的test的实现部分填加下列代码
response.Write('Hello World!');
在hello.asp中替换{Insert Method name here}为test 方法
然后保存全部工程文件,选择 Run->Register Activex Server 注册组件
将hello.asp文件复制到你的iis中执行asp的文件夹,执行即可。
/*------------------------
下面是全部 HelloASP.pas 代码
----------------------------*/
unit helloASP;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ComObj, ActiveX, AspTlb, HelloWorld_TLB, StdVcl;
type
Thello = class(TASPObject, Ihello)
protected
procedure OnEndPage; safecall;
procedure OnStartPage(const AScriptingContext: IUnknown); safecall;
procedure test; safecall;
end;
implementation
uses ComServ;
procedure Thello.OnEndPage;
begin
inherited OnEndPage;
end;
procedure Thello.OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
end;
procedure Thello.test;
begin
response.Write('Hello World!');
end;
initialization
TAutoObjectFactory.Create(ComServer, Thello, Class_hello,
ciMultiInstance, tmApartment);
end.
/*------------------------------------------------------
下面是hello.asp代码
-------------------------------*/
<HTML>
<BODY>
<TITLE> Testing Delphi ASP </TITLE>
<CENTER>
<H3> You should see the results of your Delphi Active Server method below </H3>
</CENTER>
<HR>
<% Set DelphiASPObj = Server.CreateObject("HelloWorld.hello")
DelphiASPObj.test
%>
<HR>
</BODY>
</HTML>
/*------------------------------------
helloworld.dpr 文件代码
-------------------------------------*/
library HelloWorld;
{%File 'hello.asp'}
uses
ComServ,
HelloWorld_TLB in 'HelloWorld_TLB.pas',
helloASP in 'helloASP.pas' {hello: CoClass};
exports
DllGetClassObject,
DllCanUnloadNow,
DllRegisterServer,
DllUnregisterServer;
{$R *.TLB}
{$R *.RES}
begin
end.
继续选择菜单File->New->Other 选择 Activex->Active Server Object 在CoClass Name 中添入hello
保存库文件为 helloASP.pas 保存asp文件为hello.asp
选择 Ihello节点 右击 New->Method 新建一个方法 将方法名(name)改为 test 在helloasp.pas中的test的实现部分填加下列代码
response.Write('Hello World!');
在hello.asp中替换{Insert Method name here}为test 方法
然后保存全部工程文件,选择 Run->Register Activex Server 注册组件
将hello.asp文件复制到你的iis中执行asp的文件夹,执行即可。
/*------------------------
下面是全部 HelloASP.pas 代码
----------------------------*/
unit helloASP;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ComObj, ActiveX, AspTlb, HelloWorld_TLB, StdVcl;
type
Thello = class(TASPObject, Ihello)
protected
procedure OnEndPage; safecall;
procedure OnStartPage(const AScriptingContext: IUnknown); safecall;
procedure test; safecall;
end;
implementation
uses ComServ;
procedure Thello.OnEndPage;
begin
inherited OnEndPage;
end;
procedure Thello.OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
end;
procedure Thello.test;
begin
response.Write('Hello World!');
end;
initialization
TAutoObjectFactory.Create(ComServer, Thello, Class_hello,
ciMultiInstance, tmApartment);
end.
/*------------------------------------------------------
下面是hello.asp代码
-------------------------------*/
<HTML>
<BODY>
<TITLE> Testing Delphi ASP </TITLE>
<CENTER>
<H3> You should see the results of your Delphi Active Server method below </H3>
</CENTER>
<HR>
<% Set DelphiASPObj = Server.CreateObject("HelloWorld.hello")
DelphiASPObj.test
%>
<HR>
</BODY>
</HTML>
/*------------------------------------
helloworld.dpr 文件代码
-------------------------------------*/
library HelloWorld;
{%File 'hello.asp'}
uses
ComServ,
HelloWorld_TLB in 'HelloWorld_TLB.pas',
helloASP in 'helloASP.pas' {hello: CoClass};
exports
DllGetClassObject,
DllCanUnloadNow,
DllRegisterServer,
DllUnregisterServer;
{$R *.TLB}
{$R *.RES}
begin
end.
- 一个用delphi开发asp组件的例子
- 用Delphi开发报表打印的ASP组件
- 用Delphi开发ASP分页组件
- 用delphi编写asp使用的组件
- 用Delphi 6开发ASP上传组件详解
- 用DELPHI为ASP开发文件上载组件
- 用DELPHI为ASP开发文件上载组件
- 用DELPHI为ASP开发文件上载组件
- 用DELPHI为ASP开发文件上载组件
- 用Delphi为Asp开发文件上载组件的原理和具体实现过程
- Delphi开发ASP COM组件显示图片
- 一个Socket5的例子(Delphi)
- Delphi EnumWindows 的一个例子
- 用Delphi编写ASP的ActiveX服务器组件的问题
- 一个用asp+存取数据库的例子
- 一个简单的用ASP.NET/C#开发的组件化Web应用程序(附源代码)
- ASP.NET MVC调用Delphi开发的Web报表打印activex组件
- Delphi编写asp组件
- 122道 Java面试题
- [双语阅读]感恩节:布什最后一次赦免火鸡
- Sha1 的块计算函数
- static关键字
- FCKEditor使用说明(jsp)
- 一个用delphi开发asp组件的例子
- 尝试用程序记录QQ密码
- lua移植到MTK平台小结
- python用pop3收取邮件下载附件
- oracle 将查询结果中的一列合并为一个字符串
- 一些常用的注入命令
- 爬虫程序
- java i/o 流学习心得
- 从VC6到VC9移植代码问题总结