Solved

Dynamic ActiveX Upgrade.

Posted on 1998-01-22
5
189 Views
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.
0
Comment
Question by:ndb
[X]
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
5 Comments
 
LVL 9

Expert Comment

by:cymbolic
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.
0
 
LVL 1

Author Comment

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

Expert Comment

by:LMSuporte
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

0
 
LVL 1

Author Comment

by:ndb
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.
0
 

Accepted Solution

by:
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:

SourceFileName,DestinationFileName,WhereToPutIt,RegisterIt?

Here's an example of such a file:

CoolR.DLL,MyCoolRoutines.DLL,{DLLPATH},1
CoolC.OCX,MyCoolControl.OCX,{DLLPATH},1
License.DOC,LICENSE.DOC,{EXEPATH},0
Prog.EXE,TheProgram.EXE,{EXEPATH},2

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

MAKE SURE THE RIGHTMOST CHARACTER IS A BACKSLASH (\)

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:

FullSourceName,FullDestName,Registerit

An example would be:

C:\MYDATA\COOLR.DLL,C:\Windows\system\MyCoolRoutines.DLL,1
C:\MYDATA\CoolC.OCX,C:\Windows\system\MyCoolControl.OCX,1
C:\MYDATA\LICENSE.DOC,C:\Windows\System\License.DOC,0
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:

debug.print shell("C:\PROGRAM FILES\THEPROGRAM\UPGRADE.EXE")
end
--

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:

MSCHART.OCX,MSCHART.OCX,{DLLPATH},1

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.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

696 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