关于OCX控件注册问题

'使用Shell命令
Shell "regsvr32 /s """ & 文件全路径名 & """"

'有个API用来注册.ocx的
Declare Function RegComCtl32 Lib "C:/name.dll" _
Alias "DllRegisterServer" () As Long
Declare Function UnRegComCtl32 Lib "C:/name.dll" _
Alias "DllUnregisterServer" () As Long
Const ERROR_SUCCESS = &H0

'使用:
 call RegComCtl32
If RegComCtl32 = ERROR_SUCCESS Then
MsgBox "注册成功!"
Else
MsgBox "注册失败!"
End If
其中C:/name.dll是你的控件名(全路径),在此我仅仅以name.dll为例

TO: winehero(编程人生)  我有个问题,如何判断OCX控件已被注册过?如果以注册国的话就不需要再注册了。
——————————————————————————————————

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaxctrl/html/msdn_ctlreg.asp
或者是使用如下代码判断:

Option Explicit

public function IsRegistered(byval 控件名 as string) as boolean
'其中控件名:OCXLib.ControlName
dim oCheckup as object
' Check whether the activeX control ControlName is installed and registered.
Set oCheckup = CreateObject(控件名)
IsRegistered= (Err.Number = 0)
end function

Private Sub Command1_Click()
If IsRegistered("MSFlexGridLib.MSFlexGrid.1") Then
MsgBox "MSFlexgrid已注册"
Else
MsgBox "MSFlexgrid为注册"
End If

End Sub

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页