分享:第三方组件,对是否已注册的判断
'判断第三方组件是否已注册,未注册时就执行注册,已注册,就执行后续代码.
'事件:项目事件 BeforeConnectOuterDataSource
'第三方组件:1.组件假定为"iCan.dll" 2.组件中的类的名称:"iCan.ClassName"
Dim file As String = "regsvr32.exe"
Dim arg As String = " /s " & e.ProjectPath & "iCan.dll"
On Error Resume Next
Dim obj As Object = CreateObject("iCan.ClassName")
'------------------------------------------------------------------------
If Err.Number <> 0 Then '未注册时
'注册组件
Dim Proc As New Process
Proc.File = file
Proc.Arguments = arg '参数
Proc.Start()
Proc.WaitForInputIdle()
'重启程序
Syscmd.Project.Exit()
Return
Else '已注册时
Msg("第三方组件已注册啦")
End