用vb6写asp组件的简单例子

本机调试
1、重新启动www服务
2、重新生成dll

服务器注册
1、手工注册DLL ,非常遗憾要重新启动服务器
regsvr32 RHasp.dll
反注册
regsvr32 /u RHasp.dll

2、另外还有一个方法可以不重新启动服务器
使用MTS(Microsoft Transaction Server)
MTS是IIS 4新增特色,但是它提供了巨大的改进。MTS允许你指定只有有特权的用
户才能够 访问组件,大大提高了网站服务器上的安全性设置。在MTS上注册组件的步骤如下:
(1) 打开IIS管理控制台。
(2) 展开transaction server,右键单击"pkgs installed"然后选择"new package"
(3) 单击"create an empty package"
(4) 给该包命名
(5) 指定administrator帐号或则使用"interactive"(如果服务器经常是使用administrator 登陆的话)
(6) 现在使用右键单击你刚建立的那个包下面展开后的"components"。选择 "new then component"
(7) 选择 "install new component"
(8) 找到你的.dll文件然后选择next到完成。

要删除这个对象,只要选择它的图标,然后选择delete.

参考例子
<%
‘调用的时候 server.createobject("工程名.类名")
set RHasp = server.CreateObject("RHasp.Functions")
RHasp.PrintInfo()
set RHasp = nothing
%>
'**********************************************
Private myScriptingcontext As ScriptingContext
Private myApplication As Application
Private myRequest As Request
Private myResponse As Response
Private myServer As Server
Private mySession As Session
'**********************************************

'*****************************************************************
Public Sub OnStartPage(passedscriptingcontext As ScriptingContext)
 Set myScriptingcontext = passedscriptingcontext
 Set myApplication = myScriptingcontext.Application
 Set myRequest = myScriptingcontext.Request
 Set myResponse = myScriptingcontext.Response
 Set myServer = myScriptingcontext.Server
 Set mySession = myScriptingcontext.Session
End Sub
'*****************************************************************

'*********************************
Public Sub OnEndPage()
 Set myScriptingcontext = Nothing
 Set myApplication = Nothing
 Set myRequest = Nothing
 Set myResponse = Nothing
 Set myServer = Nothing
 Set mySession = Nothing
End Sub
'********************************

Public Sub PrintInfo()
 myResponse.Write ("当前时间:" & Now())
End Sub
posted @ 2007-11-06 10:30  MaxIE  阅读(442)  评论(0编辑  收藏  举报