Results 1 to 7 of 7

Thread: [RESOLVED] Add Resource to File

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    65

    Resolved [RESOLVED] Add Resource to File

    What I need to do is add a resource to a exe file. For example, with programs like ResHacker you can do it. I was wondering if it can be done in VB6. If no one knows, then I will just have to use ResHacker via command line.

    Thanks.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Add Resource to File

    VB6 has its own Resource Editor - go to Add-Ins menu, select Add-Ins Manger and make sure that "Resource Editor" is loaded and started.
    One you did that you can go to Project menu and select "Add New Resource File".
    When you compile your project resource file will be compiled directly into exe.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    65

    Re: Add Resource to File

    I know how to do that, what I need to do is add a resource file to an already compile file. For example, imagine you have a random exe file not made in visual basic. And I want to add a resource file to it. Thats what I need to do.

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

    Re: Add Resource to File

    Quote Originally Posted by The Rogue
    I know how to do that, what I need to do is add a resource file to an already compile file.
    No I don't think you can unless you recompile the exe.

    Quote Originally Posted by The Rogue
    For example, imagine you have a random exe file not made in visual basic. And I want to add a resource file to it. Thats what I need to do.
    You can add any type of file to a Resource file and extract that file to where ever you want to when your app runs. If you wanted to add ResHacker to your exe then that isn't a problem. When you app runs you could extract ResHacker to your App.Path and Shell it from there. But don't forget, anything you add to a Resource file increases the compiled exe size by the same amount.
    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.

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

    Re: Add Resource to File

    You can use UpdateResource Function to do this, though its applications are fairly narrow.

    Normally this is used to embed manifests, replace embedded Help text, update localization string tables, etc. It is rare for this to be useful though, and generally recompiling makes the most sense. If the program isn't already aware of the resource adding it doesn't accomplish much.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    65

    Re: Add Resource to File

    Quote Originally Posted by dilettante
    You can use UpdateResource Function to do this, though its applications are fairly narrow.

    Normally this is used to embed manifests, replace embedded Help text, update localization string tables, etc. It is rare for this to be useful though, and generally recompiling makes the most sense. If the program isn't already aware of the resource adding it doesn't accomplish much.
    Thanks you, do you know how it works? I want to add a text file as the resource type "RCDATA" and the name "Settings". Would you know how to do that?

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    65

    Re: Add Resource to File

    Here is my current code, this is just to test:
    Code:
    Dim FileHandle As Long
    Dim ResData As String
    ResData = "test data"
    FileHandle = BeginUpdateResource("C:\Copy of test.exe", False)
    Call UpdateResource(FileHandle, "RCDATA", "test", 0, VarPtr(ResData), Len(ResData))
    Call EndUpdateResource(FileHandle, 0)
    But, when I put in ResHacker, the resource data shows up as "ó••"

    Anyone know why?

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