Found this useful little hint on Microsoft's site and I have encountered this problem and have seen posts from people who have as well.
The following is code in which you can automatically register your DLL or OCX at runtime, It has proven useful in the environment in which I develop. The code would go into your application.
Whenever you register or unregister a DLL the regsvr32 utility just calls out a function from withing the DLL itself. You may also use "DllUnRegisterServer" declared as a function as well.
Declare Function RegMyDLL Lib "<Path>\MyDLL.DLL" Alias _
"DllRegisterServer" () as Long
private sub TestForDLL
On Error goto ErrorHandler
dim RegMyDLLAttempted as Boolean
dim objSomeObject as Object
'if the dll is not registered then it will generate
' an error 429 at the following line.
set objSomeObject = CreateObject("MyDLL.Class")
set objSomeObject=nothing
exit sub
ErrorHandler:
If err.number=429 then
if RegMyDLLAttempted then
'error in registering do something else
else
RegMyDLL
RegMyDLLAttempted=True
Resume
end if
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.