VB6 Self Register OCXsAuthor: Dave Date: 02.04.15 - 4:22am One of the tricks with Visual Basic six is that you often depend on using ActiveX DLLs or OCX controls which must be registered on the system before use. Typically I would just include a batch file to copy them to the system 32 directory and then register them so user clicks run me.bat and you're all set small note in the readme. With the advent of 64-bit operating systems this is no longer sufficient because there is a 64-bit version of cmd.exe as well as regsvr32.exe. If user just double clicks on a batch file on a 64-bit version of Windows it automatically runs the 64-bit versions Of these programs. The problem is is that it registers the OCX control as if it was a 64-bit control which it is not. I looked a little bit on how to get cute and detect this from a batch file and it was not worth the time. With just a small bit of thought I realized that my Visual Basic six application could register its own OCX controls that it required when it started up as long as it started from a module and sub main versus using a form as it startup object which would try to load the dependencies immediately. this nuance of VB 6 Really works in our favor here! I wish I had thought of this earlier, and realized that the VB6 applications can register their own dependencies at runtime in this manner. Another neat trick, lets say your ocx uses a standard windows dll. In my example I am working with my scintinilla wrapper scivb.ocx and the scilexer.dll. So the ocx wont be loaded until the form hosting it is first shown. I had a case where I wanted to load a custom scilexer dll just for this one specific application. This can be done. Use loadlibrary to load the specific dll before the form shows, then thats the copy that will be used by the ocx even in the real one is sitting in the same directory as the ocx. Pretty handy little trick! here are the highlights broken down in logic order: ---------------------------------------------------
example auto elevate permissions so you can write to HKLM for sure: * assuming no classes from it are used as global variables in your code **you could register itself manually without regsvr32, its actually the activex dll/ocx itself which does it through the DllRegisterServer export vb6 automatically builds in, but since regsvr32 is a system component and always guaranteed to be there its easier just to let it do it. Comments: (3)On 10.15.15 - 2:42am Daniel wrote:
On 11.03.19 - 4:01pm Shareef wrote:
On 11.03.19 - 6:37pm Dave wrote:
|
About Me More Blogs Main Site |
|||