ʹÓÃVB½«ASP´úÂë·â×°µ½DLLÎļþÍêÕûʵÀý
ʹÓÃVB½«ASP´úÂë·â×°µ½DLLÎļþÍêÕûʵÀý
http://blog.csdn.net/cncco/archive/2007/10/20/1834865.aspx
ÓÃVB·â×°ASP£¬½¨Á¢SayHello²âÊÔ³ÌÐò
1¡¢´ò¿ªVB6£¬Ð½¨ActiveX DLL
2¡¢ÔÚ¹¤³ÌÒýÓÃÖмÓÈëMicrosoft Active Server Pages Object LibraryÑ¡Ôñ
3¡¢Ìî¼Ó´úÂëÈçÏ£º
'Code Start
'ÉùÃ÷²¿·Ö
Private MyScriptingContext As ScriptingContext
Private MyApplication As Application
Private MyRequest As Request
Private MyResponse As Response
Private MyServer As Server
Private MySession As Session
'ÏÂÃæ¶¨Ò幫Óú¯Êý£¨ÔÚVBÖзÃÎÊASP¶ÔÏ󣬼´ÔÚVBÖпÉÒÔÓÃMyApplicationµÈͬÓÚASPÖеÄApplication¡¢MyRequestµÈͬÓÚASPÖеÄRequest¡¢ MyResponseµÈͬÓÚASPÖеÄResponse¡¢ MyServerµÈͬÓÚASPÖеÄServer¡¢ MySessionµÈͬÓÚASPÖеÄ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
'½¨Á¢×Ô¶¨Ò庯ÊýSayHello
Public Sub SayHello()
MyResponse.Write ("Hello World")
End Sub
'Code End
4¡¢½«ÀàÃû¸ÄΪ£ºHelloWorld ½«¹¤³ÌÃû¸ÄΪ£ºTestVBCode
5¡¢Éú³ÉTestVBCode.DLLÎļþ£¬²¢Ê¹ÓÃWindowsÔËÐÐ×¢²á×é¼þÃüÁîRegsvr32 ·¾¶\TestVBCode.DLL×¢²áºó¼´¿ÉʹÓᣣ¨Ð¶ÔØ×é¼þÃüÁîΪRegsvr32 /u ·¾¶\TestVBCode.DLL£©
6¡¢½¨Á¢Test.aspÎļþ£¬´úÂëÈçÏÂ
<%
'VB×Ô½¨º¯Êýµ÷Óøñʽ
'Set ¶ÔÏóÃû=Server.CreateObject("¹¤³ÌÃû.ÀàÃû")
'¶ÔÏóÃû.×Ô½¨º¯ÊýÃû
Set MyTestObj = Server.CreateObject("TestVBCode.HelloWorld")
MyTestObj .SayHello
%>
7¡¢ÔËÐÐTest.aspÎļþ½á¹ûÏÔʾÈçÏ£º
Hello World
=================
ÒÔÉÏ´úÂëÔÚVB6,Win2003ϲâÊÔͨ¹ý.
˵Ã÷:
ÉùÃ÷²¿·Ö:ÎÒÃÇÔÚµ÷ÓÃ×Ô¼ºµÄaplactionʱ,ÏÈÒªÉùÃ÷
OnStartPage²¿·Ö:µ±ASPÖ´ÐÐʱ¾ÍÊÇÔÚ·þÎñÆ÷ÉÏ´´½¨ÕâÐ
Ïà¹ØÎĵµ£º
ÒÑÖªÓÐÒ»¸öXMLÎļþ£¨bookstore.xml£©ÈçÏ£º
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
<price>5.95</price>
</book>
< ......
Option Explicit
Private Const ERROR_CACHE_FIND_FAIL As Long = 0
Private Const ERROR_CACHE_FIND_SUCCESS As Long = 1
Private Const ERROR_FILE_NOT_FOUND As Long = 2
Private Const ERROR_ACCESS_DENIED As Long = 5
Private Const ERROR_INSUFFICIENT_BUFFER As Long = 122
Private Const MAX_PATH As Long ......
Ò»Ö±ÏëдÏÂÊý¾Ý¿â²Ù×÷·½ÃæµÄ£¬Ö»ÊÇûʲôʱ¼ä£¨ºÃÏñÊǽè¿Ú£¬Ó¦¸ÃÊÇÀÁ»òÕßûÐÄÇé°É£¬ºÇºÇ£©¡£×î½ü·¢ÏÖCSDNÉÏ
»¹ÊÇÿÌìÓÐÈËÒªÎÊÕâЩÄÚÈÝ£¬ÎÒÓеÄʱºò¾ÍÀÁµÄ»Ø´ð£¬ºÇºÇ£¬Ö÷Òª²»¶ÏµÄÈ¥ÕÒ´úÂë¸øËûÃÇÀÛ°¡¡£ËùÒÔ»¹ÊÇÌý¸ßÈ˵ģ¬À´
¸öÒ»ÀÍÓÀÒÝ£¬×Ô¼ºÖØÐÂÎÂϰÏ£¬Ò²ºÃ¸øÆäËûÈËһЩ°ïÖú¡£
Õâ¸öÊ ......
Dim rs As ADODB.Recordset
Dim sqlstr As String
'²éѯ
sqlstr = "select * from ±íÃû where ×Ö¶ÎÃû = '" & ²éѯµÄÄÚÈÝ & "'"
rs = VScn.Execute("" & SqlSt ......
GetAllSettings£¨appname£¬section£©
GetSetting£¨appname£¬section£¬key[£¬default]£© £º¶Áȡע²á±íÐÅÏ¢
SaveSetting appname£¬section£¬key£¬setting£ºÏò×¢²á±íÖÐдÈëÒ»¸ö×¢²áÐÅÏ¢
deletesetting appname£¬section£¬key£¬setting£ºÉ¾³ý×¢²á±íÐÅÏ¢
·appname£ºÓ¦ÓóÌÐòÃû£¬×Ö·û´®ÀàÐÍ£¬Óû§Ö¸¶¨
·sec ......