How can u register a dll/ocx (using regsvr32) on runtime the first time a program is loaded, and then not again? (as in, if its already registered, dont register it again)
Printable View
How can u register a dll/ocx (using regsvr32) on runtime the first time a program is loaded, and then not again? (as in, if its already registered, dont register it again)
I forget where I got this, but it may work
Code:Declare Function RegComCtl32 Lib "ComCtl32.OCX" _
Alias "DllRegisterServer" () As Long
Declare Function UnRegComCtl32 Lib "ComCtl32.OCX" _
Alias "DllUnregisterServer" () As Long
Const ERROR_SUCCESS = &H0
If RegComCtl32 = ERROR_SUCCESS Then
MsgBox "Registration Successful"
Else
MsgBox "Registration Unsuccessful"
End If
If UnRegComCtl32 = ERROR_SUCCESS Then
MsgBox "UnRegistration Successful"
Else
MsgBox "UnRegistration Unsuccessful"
End If
is there any other way to do it without using api?
Why not just register it when you install your program?
It seems that would be alot easier.;)
the installer i use wont do that..
Oh...weren't you asking about installers earlier. Inno Setup will do that. Give it a try it's really not that hard especially if you use one of the 3rd party programs that you can use with it. Just keep testing the install out on your system until you get the installation just right. If you want some help with Inno Setup just ask. Alot of people here could help you out.
hehe thats the exact program i use - i dont use any 3rd party tools, just inno, but it doesnt offer to register dlls or ocxs. I gave it to one of my friends to test, but it doesnt work (as in, it doesnt register the dll)
Well let's see either you don't have it setup to register...Here's a sample line from one of my Inno Scripts that will register the file MSVBVM60.dll when the computer restarts. AlwaysRestart=true prompts the user to restart computer.
[Setup]
AlwaysRestart=true
[Files]
Source: D:\ServicePack5\vb6sp5sys\MSVBVM60.dll; DestDir: {sys}; Flags: restartreplace uninsneveruninstall regserver; CopyMode: alwaysskipifsameorolder
Or maybe the file is already on your friends computer, and it isn't being installed.
You should look into IS Tool for Inno-Setup. All you do is go through a bunch of menus making your choices for how to install, and then it spits the Inno script out for you, and it can also compile the script using Inno's compiler. Too Easy. Plus it's Free.
RegSvr32.exe is the program used to register dll's and Ocx's. You can find this file in your Systems Folder. You can use the code
This will register your dll and OCX. Once you have registered, have a value stored in registry. Every time before calling the registry finction, check for the value.Code:Shell RegSvr32.exe <your app name with path>
You can also use the ShellExecute api function instead of shell. It has options for passing arguments to the command line.
BTW, you can also use GPInstall as your installer. Its also free as InnoSetup but does register the dll's and OCX's