各位大侠,我在MJTD里下载了自动注册控件的函数,倒是方便了不少.如下例:
Sub TEST() Dim filename As String filename = "d:\vb98\vba6.dll" Call AutoRegFile(filename) '调用AutoRegFile函数自动注册控件 End Sub Function AutoRegFile(filename As String) '自动注册控件 '语法 AutoRegFile FileName) '参数:FileName:文件名,必须包含路径 Dim reged As Boolean Dim RegFile1 As String Dim RegFile2 As String Dim BeReg As String Dim RetVal BeReg = Dir(filename) If BeReg <> "" Then RegFile1 = Environ("windir") & "\system\regsvr32.exe " RegFile2 = Environ("windir") & "\system32\regsvr32.exe " If Dir(RegFile1) <> "" Or Dir(RegFile2) <> "" Then If Dir(RegFile1) <> "" Then RegFile1 = RegFile1 & "/s" & " " & BeReg RetVal = Shell(RegFile1, 1) Else RegFile2 = RegFile2 & "/s" & " " & BeReg RetVal = Shell(RegFile2, 1) End If Else MsgBox "找不到regsvr32.exe文件,你可能无法使用本软件!", vbCritical, "无法自动注册控件" End If Else MsgBox "找不到控件文件!", vbCritical, "无法自动注册控件" End If End Function
现在的问题是:如何判断该控件是否已经注册呢?即如果上面的过程这样写
Sub TEST() Dim filename As String filename = "d:\vb98\vba6.dll"
if <该控件尚未注册> then
Call AutoRegFile(filename) '调用AutoRegFile函数自动注册控件
endif End Sub
这<该控件尚未注册> 里的代码如何写呢?
|