Delphi编写组件封装asp代码的基本步骤(编译出现的问题) ( 积分: 50 )

  • 主题发起人 myveremy
  • 开始时间
M

myveremy

Unregistered / Unconfirmed
GUEST, unregistred user!
编写一个”hello world!”的示例。我这里用的是Delphi 6。
1.文件->新建->其他->ActiveX->ActiveX Library,然后保存成showdll.dpr
2.再次,文件->新建->其他->ActiveX->ActiveX Server Object,填写CoClassName:showhello,其他不变,点击ok。
3.现在开始写程序,先添加一个方法。选择Ishowhello->右键->New->Method,填写方法名称:sayworld。
4.现在开始写程序,将Unit1保存成show.pas,然后添加方法sayworld的代码
show.pas的全部代码如下:
unit show;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ComObj, ActiveX, AspTlb, showdll_TLB, StdVcl;
type
Tshowhello = class(TASPObject, Ishowhello)
protected
procedure OnEndPage
safecall;
procedure OnStartPage(const AScriptingContext: IUnknown)
safecall;
procedure sayworld
safecall
//sayworld方法
end;
implementation
uses ComServ;
procedure Tshowhello_OnEndPage;
begin
inherited OnEndPage;
end;
procedure Tshowhello_OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
end;
procedure Tshowhello.sayworld()
//定义sayworld方法
begin
response.Write('Hello world')
//里边的语法和asp一样的写法了,就在这里封装了。
end;
initialization
TAutoObjectFactory.Create(ComServer, Tshowhello, Class_showhello,
ciMultiInstance, tmApartment);
end.
5.点击运行,编译成dll, 并自动注册了。这时候会提示:
connect debug project unless a host appliction is define.use the run|parameters...dialogbox
6.让你放到web服务器上运行,好了现在写个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(&quot;showdll.showhello&quot;)
DelphiASPObj.sayworld
%>
<HR>
</BODY>
</HTML>


报错:
Microsoft VBScript 编译器错误 错误 '800a03f6'
缺少 'End'
/iisHelp/common/500-100.asp,行242
服务器对象 错误 'ASP 0177 : 800401f3'
Server.CreateObject 失败
/activex/showhello.asp,行12
无效的 ProgID。 若要获取关于此消息的更多的信息,请访问 Microsoft 联机支持站点: http://www.microsoft.com/contentredirect.asp 。
 
编写一个”hello world!”的示例。我这里用的是Delphi 6。
1.文件->新建->其他->ActiveX->ActiveX Library,然后保存成showdll.dpr
2.再次,文件->新建->其他->ActiveX->ActiveX Server Object,填写CoClassName:showhello,其他不变,点击ok。
3.现在开始写程序,先添加一个方法。选择Ishowhello->右键->New->Method,填写方法名称:sayworld。
4.现在开始写程序,将Unit1保存成show.pas,然后添加方法sayworld的代码
show.pas的全部代码如下:
unit show;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ComObj, ActiveX, AspTlb, showdll_TLB, StdVcl;
type
Tshowhello = class(TASPObject, Ishowhello)
protected
procedure OnEndPage
safecall;
procedure OnStartPage(const AScriptingContext: IUnknown)
safecall;
procedure sayworld
safecall
//sayworld方法
end;
implementation
uses ComServ;
procedure Tshowhello_OnEndPage;
begin
inherited OnEndPage;
end;
procedure Tshowhello_OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
end;
procedure Tshowhello.sayworld()
//定义sayworld方法
begin
response.Write('Hello world')
//里边的语法和asp一样的写法了,就在这里封装了。
end;
initialization
TAutoObjectFactory.Create(ComServer, Tshowhello, Class_showhello,
ciMultiInstance, tmApartment);
end.
5.点击运行,编译成dll, 并自动注册了。这时候会提示:
connect debug project unless a host appliction is define.use the run|parameters...dialogbox
6.让你放到web服务器上运行,好了现在写个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(&quot;showdll.showhello&quot;)
DelphiASPObj.sayworld
%>
<HR>
</BODY>
</HTML>


报错:
Microsoft VBScript 编译器错误 错误 '800a03f6'
缺少 'End'
/iisHelp/common/500-100.asp,行242
服务器对象 错误 'ASP 0177 : 800401f3'
Server.CreateObject 失败
/activex/showhello.asp,行12
无效的 ProgID。 若要获取关于此消息的更多的信息,请访问 Microsoft 联机支持站点: http://www.microsoft.com/contentredirect.asp 。
 
在WEB服务器上 regsvr32 showdll.dll
 
谢谢 东兰梦舞。注册完regsvr32 showdll.dll 后,排除了无效的 ProgID
但是现在又出了个问题:
Microsoft VBScript 编译器错误 错误 '800a03f6'
缺少 'End'
/iisHelp/common/500-100.asp,行242
Microsoft VBScript 运行时错误 错误 '800a01fb'
出现一个意外错误: 'sayworld'

/activex/showhello.asp,行11
 
搞不定啊!大伙帮我看看!
 
汗。。。。。。
很遺憾沒能幫你搞定。
 
c:/winnt/help/iishelp/common/500-100.asp的问题
从别的机子上考一个替换试试,反正不是你代码的问题
重装IIS也可以,或者在 自定义错误信息 里把它删掉
 
在Tools - > environment opation ->type lib->language 改成pascal 重新编译
 
这个问题还是没解决,等待高手解答。
 
顶部