HOWTO: Register Your Custom ActiveX DLL from a ClientLast reviewed: September 4, 1997Article ID: Q173407 |
The information in this article applies to:
SUMMARYIf a compiled client application attempts to reference an object contained in an ActiveX DLL that is not currently or correctly registered on the machine, the following run-time error is generated:
"ActiveX component can't create object or return reference to this object (Error 429)"This error will not occur when testing in the Visual Basic IDE. In the development environment Visual Basic will return a compile error:
"User-defined type not defined" -or- "Can't find project or library"This article details a method that can be used to ensure that your client application correctly traps for and resolves error 429 at run-time if the ActiveX DLL is present on the machine but not correctly registered.
MORE INFORMATIONBelow are steps for creating both an ActiveX DLL server and a client application. The client application is designed to trap for error 429. If the error occurs, the ActiveX server will be registered through code. In this example, MyServerObject.DLL is the ActiveX server. MyClient.Exe is the client application.
Step-by-Step Instructions for Creating MyServerObject.DLL
Step-by-Step Instructions for Creating MyClient.Exe
End If End Sub
Private Sub Command1_Click() Dim MyObj As New MyObject MyObj.MyProperty = "Hello" MsgBox MyObj.MyProperty End Sub Windows Explorer. From the Start menu, choose Run, and in the Run dialog, type the following command:
RegSvr32.Exe /U <Path>\MyServerObject.Dll
where <Path> is the full path to MyServerObject.Dll. that registration of MyServerObject.dll is being attempted because it is not already registered. As demonstrated with the example above, when working with your own client application there are two basic tasks that must be accomplished. First, you need to publicly declare the DllRegisterServer function:
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.
Programmatic RegistrationAll ActiveX DLLs created with Visual Basic 5.0 export the DllRegisterServer and DllUnregisterServer functions. These functions can be declared in a Visual Basic client and called to self-register or unregister an ActiveX DLL. For example, the following declaration could be used to declare a function which would register the custom ActiveX DLL MyServerObject.DLL:
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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |