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

ID: 1452778
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

ID: 1452779
This doesn't work. Even when I try to register it manualy.

Expert Comment

ID: 1452780
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

ID: 1452781
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
ID: 1452782
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ms access #TYPE! error on report when no data 4 75
How to create a duplicate finder Application 9 120
Excel object stays open 19 73
VB6 - Convert HH:MM into Decimal 8 54
Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

776 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