Results 1 to 21 of 21

Thread: [RESOLVED] Icluding OCX files in VB6 executable

  1. #1

    Thread Starter
    Member
    Join Date
    May 2008
    Posts
    47

    Resolved [RESOLVED] Icluding OCX files in VB6 executable

    Hello,

    I wanted to share some software with a friend, but when I give him the exe file, he gets a missing ocx file error. I do use some third party ocx files in the software. Is there an option to include these ocx files for distribution in the exe?

    Thanks!
    -Dan

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Icluding OCX files in VB6 executable

    You can include anything you want in your installation and setup package.

    What installer are you using to distribute your program?

  3. #3

    Thread Starter
    Member
    Join Date
    May 2008
    Posts
    47

    Re: Icluding OCX files in VB6 executable

    I was just handing over the exe file. Guess this isn't enough? Are there any free ones out there that I can include the ocx files?

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Icluding OCX files in VB6 executable

    It's not enough... for an explanation of why see the article Why doesn't my program work on another computer? from our Classic VB FAQs (in the FAQ forum, which is shown near the top of our home page)

    That includes a link to our Application Deployment FAQ, which includes links for downloads and documentation for various installers (including Package & Deployment Wizard, which comes with VB).

  5. #5

    Thread Starter
    Member
    Join Date
    May 2008
    Posts
    47

    Re: Icluding OCX files in VB6 executable

    Thank you, i missed this.

  6. #6
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Icluding OCX files in VB6 executable

    In many cases you can just supply the EXE and the OCX files and tell your friend to put everything in the same directory. I have done this many time over without any problems. People would go to my website and download the zip file that contained only the EXE and the OCX files and there was no problem.

  7. #7
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Icluding OCX files in VB6 executable

    Quote Originally Posted by jmsrickland
    In many cases you can just supply the EXE and the OCX files and tell your friend to put everything in the same directory. I have done this many time over without any problems. People would go to my website and download the zip file that contained only the EXE and the OCX files and there was no problem.
    This is a Very Bad Idea.

    The point of DLLs is that they are normally shared among applications. This is less true of a custom DLL/OCX created as part of a specific application, but even more true for standard components like the Winsock control which is widely used.

    Putting a COM DLL or OCX next to a VB6 application risks having the program invoke the library's DLLRegisterServer entrypoint, which will register the library in place.

    If you do this and subsequently the user installs another program that uses the same library everything will be fine until the first program is deleted or moved. The now-faulty registry entries are still there but the library can no longer be found. This leaves the second program broken (and possibly the first) as well as other programs the user subsequently tries to install.

    Either use a proper installer (which should locate the shared library in a shared location and use proper usage-counting so uninstalls do not unregister and remove it until the last program is uninstalled) or create an isolated application. How To Build and Service Isolated Applications and Side-by-Side Assemblies for Windows XP.

    This is a big part of what is called "DLL Hell."

    The attached image shows an example of such a faulty registration.
    Attached Images Attached Images  

  8. #8
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Icluding OCX files in VB6 executable

    Well, what can I say. I have downloaded many programs (EXE) with the OCX's and have not had any problems and like I said above have allowed many zip files with only the exe's and ocx's and again without any problems.

    Maybe it is a bad idea; I didn't say it was or wasn't I just said what I said and I have never had anyone complain about it and furthermore complain about the application not working. In the case of the OP if all he wants to do is to give a copy to his friend then what the heck give him the exe and the ocx and if it works leave it at that. If it doesn't work then that's another issue.

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Icluding OCX files in VB6 executable

    Getting away with it so far is down to luck - it doesn't take much for that to change.

    Not getting complaints is due to the problems appearing to be caused by other programs, so the blame for your mistakes is passed elsewhere.

  10. #10
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Icluding OCX files in VB6 executable

    You could also put the ocx in a resource file and have sub Main check if it exists, if not extract it and register it
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  11. #11
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Icluding OCX files in VB6 executable

    That is marginally better, but even if you install to the correct location (which the user may not have permission for) it is still likely to be missing out part(s) of the process.

  12. #12
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Icluding OCX files in VB6 executable

    Not getting complaints is due to the problems appearing to be caused by other programs

    You're making it sound as if some problem is caused by other programs where I said there was no problems.

    OK, to make it short, yes it is not a good idea but then you need to tell that to the thousands of people who put their programs and ocx's in a zip file and then allow you to download them from many different sites. I personally have never had any problems whatsoever downloading any zip (exe and ocx's and dll's) file into a folder and running the application. For large scale applications and large scale distributions then no it shouldn't be done that way but for perhaps a one or two time only thing, bad or not bad, it will probably work.

    Correct me if I am wrong here.

    Let's say there is an OCX (or a DLL) in the system's directory of your friend and you want to send a copy of your application (which includes either an older or a newer version of the same file or at least with the same name) and you don't want to have your file overwrite the one already in his system's directory and you want to make sure your application uses the OCX/DLL that you supplied then putting that OCX/DLL in the same folder as the application will insure that it will be used instead of the one in the system's directory and you have not overwritten the original file. VB will first look in the application's folder before it looks in the system's directory.
    Last edited by jmsrickland; Sep 25th, 2008 at 11:21 AM.

  13. #13
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Icluding OCX files in VB6 executable

    You didn't say there were no problems, you said that you haven't had any, and nobody has reported any to you.

    In what you "quoted" (there are proper quote tags you know ) I was pointing out that the reason people wouldn't report problems is that they don't think the problems are caused by your program, as they appear when doing something with a different program (and thus they assume it is the other programs fault).

  14. #14
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Icluding OCX files in VB6 executable

    If you really want to do XCopy-style deployment there is an approved way to do it for Windows XP (especially SP2+) and later. It's the "isolated application with private assemblies" approach described in that MSDN article I linked above.

    Sadly Microsoft never has and probably never will provide tools for doing this with VB6 programs, even though the technology was developed specifically with VB6 in mind.

    Registration-Free Activation of .NET-Based Components: A Walkthrough
    Applies to:
    Microsoft Windows Server 2003
    Microsoft Windows XP Service Pack 2
    Microsoft .NET Framework version 1.1
    Microsoft Visual Studio .NET 2003
    Microsoft Visual Basic 6.0
    A few 3rd party tools exist to facilitate this with VB6 programs and components. The Mage and MageUI tools in more recent versions of the Windows SDK might be useful as well - be sure if you use Mage/MageUI you get versions contemporary with VS 2005 SP1 (older ones have fatal flaws).

    None of the tools make the process a "no brainer" since you still have to understand what to deploy. Some common VB6 dependencies do not have DEP files for example, so neither the PDW nor an XCopy deployment packager will always be able to locate sub-dependencies. They may also pick non-deployable dependencies that you must manually skip.

    Some other tools for XCopy-packaging VB6 programs include:
    These can be used to create a set of files you can distribute as a ZIP archive or even a self-extracting archive.

    Unlike using an installer technology they won't create Start Menu shortcuts, etc. or install into Program Files. They will let you package DLLs and OCXs alongside your programs without ever altering the registry though.

    The resulting programs are "portable" in the sense you can move the application folder around or even onto a USB flash drive. The caveat is you cannot deploy the VB6 runtime components this way, which means you really should test your programs against the versions of the runtimes that come with XP SP2 and SP3 (XP SP3 has the same VB6 runtimes as Vista and Vista SP1). In some cases you may find that your programs will work fine even in XP and XP SP1 depending on the specific dependencies involved - OCXs tend to be more problematic than DLLs.

  15. #15
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Icluding OCX files in VB6 executable

    You didn't say there were no problems, you said that you haven't had any, and nobody has reported any to you.

    In what you "quoted" (there are proper quote tags you know ) I was pointing out that the reason people wouldn't report problems is that they don't think the problems are caused by your program, as they appear when doing something with a different program (and thus they assume it is the other programs fault).


    How do suppose a problem could/would occur with another program? No way since no other programs would use the OCX that was placed in the directory of the application for which it was intended. That the whole idea; to keep it isolated from the rest of the system. The only way other programs would have problems would be if they loaded that same OCX and that would be the fault of the user because he was suppose to keep it in only one directory and not let it get into the main stream of the system files or other directories.

    Putting the application and it's associated files in one directory insures that nothing else in the system can be affected by it. The risk comes in when the associated files are placed in the system's directory, not in the application's directory. Besides, you are supoosed to stay out of the system's directories.

    Any way, I was just stating that you could do it that way; not to argue good, bad, or whatever
    Last edited by jmsrickland; Sep 25th, 2008 at 12:42 PM.

  16. #16
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Icluding OCX files in VB6 executable

    Have you read post #7?

    Putting the file in a different location does not solve the problem - it does not guarantee isolation.

    If the files get registered at all (which can be automatic when your program uses them), you have created a problem that you could have avoided.

  17. #17
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Icluding OCX files in VB6 executable

    Agreed. So that does indeed makes it a bad idea.

  18. #18
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Icluding OCX files in VB6 executable

    I think Microsoft would have disabled this auto-registration long ago... if it wouldn't break so many VB applications. I don't know how far it goes back, maybe even to VB4 32bit programs but probably at least to VB5 programs.

    One of the hazards of classic VB development is getting by with no support from the vendor. So even as things that seemed like a good idea at the time are found to be less so later on... it is up to us to deal with them on our own.


    Most people probably don't even realize they aren't supposed to be using regsvr32 runs as part of installing an application. Some of the reasons are described in the Windows Installer documentation at SelfReg Table. This is why the PDW, Inno Setup, and the like aren't the best packaging tools to use. They only know how to use component library self registration.

    Of course that doesn't stop us from using them, and you can do the very same "wrong" thing in an Installer MSI too. Installation/setup is quite a minefield.

  19. #19
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Icluding OCX files in VB6 executable

    Well if I had written a program which required a third party DLL or OCX or even if I made the DLL or OCX and I was just going to give a copy to my friend I would just give him the exe and the ocx. The heck with wrapping it up in a distribution package. My first post was made based on that pretense. Now on the other hand if it was going to be widley distributed it then I would give second thought. I am quite amazed however that most of the applications I download (and I mean commercial stuff) are all nicely placed in their own directories with all the DLLs and OCX's in there too. I do not see these same files in my system directory. I agree with post #7 but for just what the OP wanted I just simply stated that you could do it that way and save yourself the trouble for that one time only occurance. Is it a bad idea? Based on post #7, yes, based on giving your friend a copy and it's a one time only thing then who cares.

  20. #20

  21. #21

    Thread Starter
    Member
    Join Date
    May 2008
    Posts
    47

    Re: Icluding OCX files in VB6 executable

    Thanks for all of the info guys! I'm marking this as Problem Solved (or whatever)

    Thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width