|
分享一下网络资源,自动注册控件代码
Sub AutoReg()
'文件路径中不得含有空格
Dim RegExe1 As String
Dim RegExe2 As String
On Error GoTo Prc_Err
RegExe1 = Environ("Windir") & "\System32\regsvr32.exe"
RegExe2 = Application.CurrentProject.Path & "\Command.ocx"
'References.AddFromFile (Application.CurrentProject.Path & "\Command.ocx") '引用类库,一般无需用到
If Dir(RegExe1) = "" And Dir(RegExe2) = "" Then
MsgBox "系统找不到Regsvr32.exe文件,不能注册控件," & vbCrLf & "您将无法正常使用本软件,正在退出…….", vbCritical, "启动错误"
DoCmd.Quit acQuitSaveNone
Else
Call Shell("Regsvr32 /s " & RegExe2, vbHide)
End If
Prc_Exit:
Exit Sub
Prc_Err:
MsgBox Error$
Resume Prc_Exit
End Sub
Sub AutoUnReg()
Dim RegExe1 As String
Dim RegExe2 As String
On Error GoTo Prc_Err
RegExe1 = Environ("Windir") & "\System32\regsvr32.exe"
RegExe2 = Application.CurrentProject.Path & "\Command.ocx" '文件路径中不得含有空格
If Dir(RegExe1) = "" And Dir(RegExe2) = "" Then
MsgBox "系统找不到Regsvr32.exe文件,不能注销控件,正在退出…….", vbCritical, "关闭错误"
DoCmd.Quit acQuitSaveNone
Else
Call Shell("Regsvr32 /s /u " & RegExe2, vbHide)
End If
Prc_Exit:
Exit Sub
Prc_Err:
MsgBox Error$
Resume Prc_Exit
End Sub<BR both"> |
|