* Use of this CLASS and ASP can manage the registration page inside your DLL
* CLASS WIN 2K in the test pass
* Note: The use of the CLASS need to establish an XML document. The documents are as follows. Notepad will open the following three lines of the XML document *.
* Example:
* Dim objRegsvr32
* Set objRegsvr32 = new Regsvr32
* With objRegsvr32
* If. LoadXml ("../ MyDll.xml ") then
* Call Response.Write ( "XML document loading error")
* Set objRegsvr32 = nothing
* Response.End
* End if
* Select case. AddNode ( "F: \ web \ cw31072 \ dll \ test \ MyClass.dll", true) 'Add new entries and register DLL
* 1 case
* Call Response.Write ( "entry has been added to the XML file! And successfully registered DLL!")
* Case 0
* Call Response.Write ( "entry has been added to the XML file! But the registration DLL failed!")
* Case -1
* Call Response.Write ( "XML document has been the entry! The DLL has also been registered!")
* End select
* End with
* 'This CLASS is very simple, there is also some way, I do not, for example, look at the know. You can open the future
* 'Look at the XML file you have to be registered and registered DLL List.
* 'XML document each entry are as follows: F: \ web \ cw31072 \ dll \ test \ MyClass.dll
* 'F: \ web \ cw31072 \ dll \ test \ MyClass.dll is your DLL file path
* 'Have registered = "1" is that the DLL has been registered, = "0" is not registered yet?
************************************************** Attachments
Class Regsvr32
Private s_objXml
Private s_objNodeRoot
Private s_strXmlPath
Private s_strAttributeName
'------------------------------------
'Objective: DLL loading configuration file xml
'Parameters: XML document addresses
'Back: load failure to return TRUE
'------------------------------------
The following is quoted fragment:
Public function LoadXml (strPath)
Set s_objXml = CreateObject ( "MSXML2.DOMdocument")
S_objXml.async = false
S_objXml.load (strPath)
If s_objXml.parseError.errorCode <> 0 then
Set s_objXml = nothing
LoadXml = true
Exit function
End if
Set s_objNodeRoot = s_objXml.documentElement
S_strXmlPath = strPath
S_strAttributeName = "already registered"
End function
'---------------------------------------------
'Objective: To add an item DLL
'Parameters: strPath: DLL files Address
'BlnReg: whether to add its registration
'Back: If after registration requirements add, on the return of a successful registration, the Registrar failed to return to 0, and the project has been a note of the return -1
'---------------------------------------------
The following is quoted fragment:
Public function AddNode (strPath, blnReg)
Dim objNewNode
Dim strStart
Dim objNode
StrStart = "0"
Set objNode = SelectNode (strPath)
If objNode is nothing then
If Reg (strPath, true) then
StrStart = "1"
AddNode = true
Else
AddNode = false
End if
S_objXml.createElement set objNewNode = ( "Dll")
Call objNewNode.setAttribute (s_strAttributeName, strStart)
ObjNewNode.Text = strPath
Call s_objNodeRoot.appendChild (objNewNode)
Call s_objXml.save (s_strXmlPath)
Else
If blnReg then
If objNode.Attributes.getNamedItem (s_strAttributeName). NodeValue = "1" then
AddNode = true
Else
If Reg (strPath, true) then
ObjNode.Attributes.getNamedItem (s_strAttributeName). NodeValue = "1"
Call s_objXml.save (s_strXmlPath)
Else
AddNode = false
End if
End if
Else
AddNode = false
End if
End if
End function
'----------------------------------------
'Objective: To delete all registered or not registered nodes
'Parameters: blnStart: 0 = unregistered, registered 1 =
'Back: implementation of the delete operation will return TRUE, or else return FALSE
'----------------------------------------
The following is quoted fragment:
Public function ReAllNode (byVal blnStart)
Dim objNode
Dim blnIsChange
BlnStart = CStr (blnStart)
For each objNode in s_objNodeRoot.childNodes
If objNode.Attributes.getNamedItem (s_strAttributeName). NodeValue = blnStart then
Call s_objNodeRoot.removeChild (objNode)
BlnIsChange = true
End if
Next
If blnIsChange then
ReAllNode = true
Call s_objXml.save (s_strXmlPath)
Else
ReAllNode = false
End if
End function
'-----------------------------------------
'Objective: To delete a particular node
'Parameters: node content
'Back: no node will return TRUE
'-----------------------------------------
The following is quoted fragment:
Public function ReNode (strPath)
Dim objNode
Set objNode = SelectNode (strPath)
If objNode is nothing then
ReNode = true
Else
Call s_objNodeRoot.removeChild (objNode)
Call s_objXml.save (s_strXmlPath)
End if
End function
'-----------------------------------------
'Objective: To find a particular node
'Parameters: strPath: node content
'Back: find on return to the node, not to return to nothing
'-----------------------------------------
The following is quoted fragment:
Private function SelectNode (ByVal strPath)
Dim objNode
StrPath = UCase (strPath)
For each objNode in s_objNodeRoot.childNodes
If UCase (objNode.childNodes.item (0). NodeValue) = strPath then
Set SelectNode = objNode
Exit function
End if
Next
Set SelectNode = nothing
End function
'--------------------------------------------
'Purpose: View DLL files in a file on the state register
'Parameters: the paper path
'Back: 1 = registered
'Unregistered 0 =
'-1 = Unable to find the document
'--------------------------------------------
The following is quoted fragment:
Public function CheckDll (strPath)
Dim objNode
Set objNode = SelectNode (strPath)
If objNode is nothing then
CheckDll = -1
Else
CheckDll = Cint (objNode.Attributes.getNamedItem (s_strAttributeName). NodeValue)
End if
End function
'--------------------------------------
'Objective: To all unregistered DLL Registry
'Back: If there is a failure to register DLL return TRUE
'--------------------------------------
The following is quoted fragment:
Public function RegAllNode ()
Dim objNode
For each objNode in s_objNodeRoot.childNodes
If objNode.Attributes.getNamedItem (s_strAttributeName). NodeValue = "0" then
If Reg (objNode.childNodes.item (0). NodeValue, true) then
ObjNode.Attributes.getNamedItem (s_strAttributeName). NodeValue = 1
Else
RegAllNode = true
End if
End if
Next
End function
'-----------------------------------------
'Objective: To register DLL
'Parameters: strPath: To register Dll File path
'BlnLoding: Does it continue to wait for the completion of the registration procedures
'Back: If blnLoging = TRUE, registered to return to True
'-----------------------------------------
The following is quoted fragment:
Private function Reg (strPath, blnLoding)
Dim objShell
Set objShell = CreateObject ( "Wscript.Shell")
If objShell.Run ( "regsvr32.exe / s" & strPath, blnLoding) = 0 then
Reg = true
End if
Set objShell = nothing
End function |