Results 1 to 12 of 12

Thread: Adding Resource To EXE

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2011
    Posts
    340

    Adding Resource To EXE

    Hello. I have a resource file that I would like to add to my VB6 EXE. The resource file contains one dll file with the ID of 101 and the name of "CUSTOM".

    I would like to know how to add the resource to my EXE so that I can compile it together and have the DLL in my exe.

    Thanks

  2. #2
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: Adding Resource To EXE

    You open up your project that you want to add the Resource file to then press CTRL+D to add a VB file, find the *.res file and add it.

    If you want to edit this res file then you have to Load VB6 Resource Editor from Add-Ins\Add-In Manager... and select VB6 Resource Editor and just put a tick in Loaded/Unloaded and Load on Startup checkboxes then you will see the green segmented cube on the menubar everytime VB starts up.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2011
    Posts
    340

    Re: Adding Resource To EXE

    Oh sorry I think I need to rephrase my question.

    Ok, I already created the resource file and added everything I want in it. I also already added the resource file to my VB6 application.

    What I'm trying to figure out is the code that loads the resource file into my app.

    As In what is the code that I need to put in Form_Load to load the resource file into my EXE.

    Like this:

    Dim FileNum As Integer
    Dim DataArray() As Byte

    DataArray = LoadResData(101, "CUSTOM")

    FileNum = FreeFile
    Open "WHAT DO I PUT HERE?" For Binary As #FileNum
    Put #FileNum, 101, DataArray()
    Close #FileNum

    Erase DataArray

  4. #4

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2011
    Posts
    340

    Re: Adding Resource To EXE

    I am trying to include my dll into my VB6 application so that I will not have to manually regsvr32 it myself.

    How can I do that?

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Adding Resource To EXE

    You ARE loading it.... that's what LoadResData(101, "CUSTOM") is doing... loading that resource into the byte array... so if it is a dll, you want to write it to a file, with the appropriate name... now after that... I don't know... since your app is already running, you can't add it as a reference so I'm not sure what you're trying to accomplish.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2011
    Posts
    340

    Re: Adding Resource To EXE

    So If I put

    LoadResData(101, "CUSTOM") into Form_Load

    I won't have to download my dll and register it?

    I have a dll file by the name of Chrome.DLL. I added this dll to a resource. I then added the resource to my VB6 application.

    I want to use my application on other computers though and the problem with that is that I have to keep registering chrome.dll in order for my EXE to work because chrome.dll is added as a reference.

    Im trying to make it so I just include/compile EVERYTHING into the one EXE file and then won't have to register the DLL anymore.

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Adding Resource To EXE

    If it's referenced, then how can you use it if it's tucked into a resource file? Even if you extract the file and write it out to the system, you'd still need to rgsvr32 in order to use it...

    Sounds like what you really need is an installer...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2011
    Posts
    340

    Re: Adding Resource To EXE

    Yes, I referenced chrome.dll. Which means I have to manually register it for every computer I want to run my program on. Are you saying there is no other way to avoid this other than making an installer?

  10. #10
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Adding Resource To EXE

    It has to be registered on the system somehow... if you don't want to do it manually, then an installer should be able to handle that for you.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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

    Re: Adding Resource To EXE

    I think the way it works is like this: During you app's load time the system loads all DLL's used by your app which all must have already been registered and puts them in their own processing space. This means that you cannot pull your DLL data out of the resource part of your app and then save it and then try to register it. Even if you could it wouldn't work as it was not loaded by the OS when your app first was launched. So, the only way is to include the DLL as part of your installer and have the installer register it for you then when your app is launched by the user the DLL is ready to go.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

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

    Re: Adding Resource To EXE

    What you seem to be asking for is static linking. VB6 doesn't support that and in any case you link .LIB files, not .DLLs.

    Of course in many cases you can use registration-free COM to avoid the need to register DLLs and OCXs. You still need to deploy them as private assemblies, but simply copying them is enough. This has been around since XP came out.

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