>在主程序里引用一个自定义的activedll类之前,怎么判断该类是否存在,或是否注册了?
思路:试着去建立一个对象,如果建立不成功,则这个类没有被注册。
使用方法:
if CretaeObjectEx("MyDll.MyClass") is nothing then
msgbox "ActiveX Dll 不能建立对象"
end if
'***********************************************************
Public Function CreateObjectEx(Class As String, Optional ServerName As String)
'目的 : 建立对象
'相关模块:
'返回:建立成功,返回对对象的引用,否则返回Nothing.
On Error GoTo PROC_ERR
Dim lngErr As Long
If IsMissing(ServerName) Then
Set CreateObjectEx = CreateObject(Class)
Else
Set CreateObjectEx = CreateObject(Class, ServerName)
End If
PROC_EXIT:
Exit Function
PROC_ERR:
lngErr = Err.Number
Set CreateObjectEx = Nothing
Debug.Print "CreateObjectEx.Err(" & Err.Number & "):" & Err.Description
GoTo PROC_EXIT
End Function
'***********************************************************
'*希望能够对你有所帮助!
'***********************************************************
'*欢迎访问的网站,给我的作品提宝贵意见!
http://www.softboyzhou.com
'*下载EasyDialog:
http://www.softboyzhou.com/download/EasyDialog.asp