Dynamic ActiveX Upgrade.

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.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
ndbAuthor Commented:
This doesn't work. Even when I try to register it manualy.
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

ndbAuthor Commented:
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.
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.