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