Dynamic ActiveX Upgrade.

Posted on 1998-01-22
Last Modified: 2008-02-01
I've written a program that uses some ActiveX DLL's and OCX's. In the futur these controls 'll be upgraded. I've tested it on my computer with just recompiling these objects but when I want to run my VB program it sais that he can't create the object.
Question by:ndb

Expert Comment

Comment Utility
Usually the reason you get a "can't create object" is because the program can't find it. Either the object is not registered on your system (setup wizard install will register them when run on target system), or if in the vb development environment, your .vbp or project file has a reference that points to an older version that is no longer there.  It's also possible the the registry information is incorrect, and points to old object source that is no longer on the system.

You can either register manually, run install using setup wizard, or if in VB design, bring it in under the tools/references menu.

Author Comment

Comment Utility
This doesn't work. Even when I try to register it manualy.

Expert Comment

Comment Utility
what was the command line you used to manually register it?
have you tried this?
  regsvr32 FileToRegister
 you can use  regsrv32 /u /s FileToRegister. wher
/u is unregister
/s is no confirmation


Author Comment

Comment Utility
I've first uninstalled the old version with regsvr32 -u and registered the new version with regsvr32 again. But my exe still points to the old one I tink.

Accepted Solution

Dr_Falken earned 100 total points
Comment Utility
This one gets kind of tricky.  You need to have the program that *USES* the DLLs and OCXs have some sort of "check for upgrade" routine.  One of your DLL's or OCX's needs to have a function that returns the their exact location in the computer (app.path, app.exename).  You will also need to know a directory that the upgrade will be found in (the data directory has worked in my experience).

With this knowledge, you can write a routine that reads a file similar to this:


Here's an example of such a file:


Your program would grab the location of the DLL and get the path from that, store that in a variable.  

It would also store APP.PATH in a variable.


At this time, substitute the proper directories from the information obtained above.  This assumes that your program knows where the upgrades are located (hopefully all in one directory).  

Now would be a good time to check the file dates and times on the all the affected files.  If the executable hasn't changed, DON'T UPGRADE ANYTHING.  This is because if you do, the old executable will attempt to use your new OCX's and DLL's.

Your program would have to read that and make ANOTHER file based on that information.  That file would look like this:


An example would be:

C:\PROG.EXE,C:\Program Files\TheProgram\TheProgram.EXE,2

Once the upgrade information is saved to disk, start up another program (we'll call it upgrade) and end your current program.  Code for that is illustrated below:


now you need to write ANOTHER program specifically for upgrading (this one will be easy).  It goes like this:

Read in the file that was created by the previous program (the upgrade file)

The exact path to the executable will be found in the line with a registration number of 2 as the destination.

Make sure the other program has completely closed out by attempting to delete the executable until you do not get an error (you will get an error trying to delete a running executable, but once it completely closes, there will be no error -once)

For each line in the file, FileCopy the source to the destination.
If the registration number (the last number) is one, call regsvr32 in a shell (REGSVR32 -S destinationfilename)

Delete the upgrade file (not the original upgrade script, just the file that was created by the previous program)

Run the original executable (by shelling the destinationfilename of the file with the registration number of 2)

End the upgrade program.
This is the effect your end users will see:

They will run the program, the program will check for an upgrade and notice that an upgrade is necessary.  It will then close the program and run the upgrader.  

The upgrader will copy the new files over the old ones and register the appropriate DLLs and OCXs, even replace the license agreement with a more up-to-date one if you like.  The program will start again - this time it is the new version of the program.

This is helpful to you because if you are on a network you can upgrade all computers simultaneously by copying the upgrade files to the upgrade directory. The next time the people run the program it will upgrade the program automatically.

If you ever add new OCXs or DLLs when you add to the program, all you need to do is modify the script and copy the file into the upgrade directory.  For example, if your program starts using the MSCHART.OCX control and you already have a network of 40 computers running your program, you just need to add this line to the upgrade script:


Then close the program on all computers and start them up again.

If they have a copy of mschart in their C:\windows\system directory already and the file dates and times are the same, it won't upgrade that file.  If they don't, it will copy the file into the correct directory and register it.

The new version will run without problems.

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now