Article ID: 173407
Article Last Modified on 7/15/2004
Property Value
---------------------------------
(Name) MyObject
Instancing 5 - MultiUse
Public MyProperty As String
Public Declare Function RegMyServerObject Lib _
"<Path>\MyServerObject.DLL" _
Alias "DllRegisterServer" () As Long
where <Path> is the full path to MyServerObject.Dll. The
"DllRegisterServer" portion of the above declaration is case-sensitive.
NOTE: For more information on this API function see Programmatic
Registration at the end of this article.
Private Sub Form_Load()
On Error GoTo Err_DLL_Not_Registered
Dim RegMyDLLAttempted As Boolean
Dim MyObj As New MyServerObject.MyObject
'The following statement will fail at run-time
'if MyServerObject is not registered.
MyObj.MyProperty = "Hello"
Set MyObj = Nothing
Exit Sub
Err_DLL_Not_Registered:
' Check to see if error 429 occurs
If Err.Number = 429 Then
MsgBox "Attempting To Register MyServerObject"
'RegMyDLLAttempted is used to determine whether an
'attempt to register the ActiveX DLL has already been
'attempted. This helps to avoid getting stuck in a loop if
'the ActiveX DLL cannot be registered for some reason.
If RegMyDLLAttempted Then
MsgBox "Unable to Register MyServerObject"
Resume Next
Else
RegMyServerObject 'Declared in Module1
RegMyDLLAttempted = True
MsgBox "Registration of MyServerObject attempted."
Resume
End If
Else
MsgBox "An Error Occurred"
End If
End Sub
Private Sub Command1_Click()
Dim MyObj As New MyObject
MyObj.MyProperty = "Hello"
MsgBox MyObj.MyProperty
End Sub
RegSvr32.Exe /U <Path>\MyServerObject.Dll
Public Declare Function RegMyServerObject Lib _ "<Path>\MyServerObject.DLL" _ Alias "DllRegisterServer" () As LongSecond, you need to trap for error 429 in the error handling routine of the Form1 Load event and attempt to recover from the error by calling the function declaration for DllRegisterServer.
Public Declare Function RegMyServerObject Lib _ "MyServerObject.DLL" _ Alias "DllRegisterServer" () As LongIn code, the "RegMyServerObject" could be called to register the DLL:
Call RegMyServerObject
Additional query words: register registry unregister unregistered
Keywords: kberrmsg kbhowto KB173407