Dynamic ActiveX Upgrade.

Posted on 1998-01-22
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

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 200 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month12 days, 2 hours left to enroll

752 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