dcsimg
Results 1 to 31 of 31

Thread: Is there a way to work around the Resource Editor?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2015
    Posts
    24

    Is there a way to work around the Resource Editor?

    Recently I started a thread concerning how to load JPGs, GIFs, PNGs, and other graphics images from a VB6 Resource File. User 'dilettante' was imminently helpful toward my figuring out how to do it with the fewest lines of code.

    Now that this ability has been unleashed in me, I'm finding it taxing to load all my images into the current program I'm writing (I have some 800 images--custom resources--to load). Furthermore, in order to maintain some sense of organization for all those images, I've come up with an ID numbering scheme to make it easy to locate individual images in my resource file because there's no way to view them at design time.

    Obviously, loading all these images one-by-one and assigning them a custom ID is going to be hugely time consuming. Is there any way to do this using a program (i.e., a program I could write that would permanently load custom resources into my .RES file with a specifically assigned ID)?

    Any help would be greatly appreciated.

    Thanks!

  2. #2
    Hyperactive Member
    Join Date
    Jun 2015
    Posts
    313

    Re: Is there a way to work around the Resource Editor?

    [...]
    Last edited by dz32; Apr 26th, 2019 at 11:31 AM.

  3. #3
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,697

    Re: Is there a way to work around the Resource Editor?

    Sure you may hit the limit of 64k per item but not sure the overall res file limit.

    You can also write a dll that contains all your resources to get beyond the limit. Plus that will make it easier to update a dll vs recompiling the exe
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,805

    Re: Is there a way to work around the Resource Editor?

    Ok, I use the .RES file extensively. Here's what I've got to say:

    • The 64K limit is some hangover to an earlier version of VB. I use VB6-SP6, and I have HUGE files in my .RES file, and they work flawlessly. Just from a quick scan, I've got one that's 3.5 meg, but there are others that may be even larger.
    • There is a funny limit of 65520 bytes, but it's not a limit. It's more of a caveat. Any file smaller than this will go in and come out perfectly. Any file larger than this will be rounded up to the nearest four-byte boundary. For many things, this doesn't hurt anything. However, for some things, if they don't come out as the exact number of bytes as they went in, it can cause problems. If your file already happens to be sized on a four-byte boundary, then there's no problem. I deal with this by keeping track of the file names (in my RES file) that are larger than 65520, and then adjust their sizes when I set them back out on disk.
    • For dealing with large numbers of files, there are a few resource builder programs around, that let your circumvent the Resource Editor Add-In. It sounds like this is what you need. You might want to give LaVolpe a shout to learn more about this. I believe there are some floating around in VB6, but I'm not absolutely certain about that. Actually I've got one, but it's just in my VB6 "junk drawer" and I haven't really played with it. You'd do better to Google. I have a couple hundred files in my RES file, but I just did it onesy-twosy years ago via the Add-In, and that's the way I continue to maintain it.
    • It's rather trivial to write a resource dump into your code. I have one built into mine. This is an easy way to just quickly get everything back out of it.
    • Note that resource file names are always upper-case with no white space. However, the LoadResData function will take care of this for you. However, this can be a bit of a problem if you use the EnumResourceNames API call. I'll let you sort that one out.
    • And yes, ActiveX.dll files can also contain resource files. In fact, I've got ActiveX.dll files in the resources of my main project. And, these also have resources. So, I suppose I have nested resources.


    That's about it I suppose.

    Good Luck,
    Elroy

    EDIT1: Ohhh, I like dz32's idea. I just saw that. If I were managing 1000s of images for some reason, that might be precisely how I'd do it.

    EDIT2: Also, if you spend a bit of time with it, you could learn about the resource compiler (RC.EXE). You can feed it a directive file on the command line which will tell it to create a .RES file out of any number of files you like. It's not going to compress them, but it will combine them. And then you can use that .RES file with your VB6 project.
    Last edited by Elroy; Jun 7th, 2017 at 04:41 PM.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,661

    Re: Is there a way to work around the Resource Editor?

    If the number of items and the total size is reasonable than using RC.EXE may be the way to go. Somebody has probably even written a GUI front-end to let you browse, drag-drop, and otherwise pick files, assign types, and then let you name/number them as you wish.

    A zip archive makes some sense, though native support is awkward. Things like zlibwapi.dll are fairly easy to use though and far more versatile than Shell based zip support. Cab archives have somewhat better native Windows support.

    Since most image formats are already compressed you might forego that and use an OLE Storage file instead. Or even use a simple Jet MDB.

    Lots of options and no clear winner.

  6. #6
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,805

    Re: Is there a way to work around the Resource Editor?

    dilettante, I know you've got some problem with it, but I make some use of wqweto's VB6 unzip code, and it works flawless for me. I pack up about 300 ASCII files with 7Zip, put them in my resources (as a single zip). And then, when I want, I drop the zipped file back onto disk, and then use wqweto's class to unzip them. This seems pretty close to doing what schnel is trying to do.

    I've never used it to unzip individual files, but I suspect it could do it. I love that it's a pure VB6 solution.

    Best Regards,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,661

    Re: Is there a way to work around the Resource Editor?

    Ahh, but it isn't VB6. It relies on runtime injection of some compiled C or something. Just the thing to trigger antivirus flags, and as far as I can recall it doesn't credit the source and may be breaking an open source license.

    In any case you'd want something that can extract the data to memory, not to disk. Maybe it can do that, I wouldn't know.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jul 2015
    Posts
    24

    Re: Is there a way to work around the Resource Editor?

    Quote Originally Posted by dilettante View Post
    Ahh, but it isn't VB6. It relies on runtime injection of some compiled C or something. Just the thing to trigger antivirus flags, and as far as I can recall it doesn't credit the source and may be breaking an open source license.

    In any case you'd want something that can extract the data to memory, not to disk. Maybe it can do that, I wouldn't know.
    As dilettante will attest, I'm not an expert vb6 programmer by any stretch of the imagination. So I'm probably biting off more than I can chew with all these recommendations. What exactly is RC.EXE? Is that a program that some other user wrote that is residing here in the forum somewhere?

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jul 2015
    Posts
    24

    Re: Is there a way to work around the Resource Editor?

    Quote Originally Posted by Elroy View Post
    Ok, I use the .RES file extensively. Here's what I've got to say:

    • The 64K limit is some hangover to an earlier version of VB. I use VB6-SP6, and I have HUGE files in my .RES file, and they work flawlessly. Just from a quick scan, I've got one that's 3.5 meg, but there are others that may be even larger.
    • There is a funny limit of 65520 bytes, but it's not a limit. It's more of a caveat. Any file smaller than this will go in and come out perfectly. Any file larger than this will be rounded up to the nearest four-byte boundary. For many things, this doesn't hurt anything. However, for some things, if they don't come out as the exact number of bytes as they went in, it can cause problems. If your file already happens to be sized on a four-byte boundary, then there's no problem. I deal with this by keeping track of the file names (in my RES file) that are larger than 65520, and then adjust their sizes when I set them back out on disk.
    • For dealing with large numbers of files, there are a few resource builder programs around, that let your circumvent the Resource Editor Add-In. It sounds like this is what you need. You might want to give LaVolpe a shout to learn more about this. I believe there are some floating around in VB6, but I'm not absolutely certain about that. Actually I've got one, but it's just in my VB6 "junk drawer" and I haven't really played with it. You'd do better to Google. I have a couple hundred files in my RES file, but I just did it onesy-twosy years ago via the Add-In, and that's the way I continue to maintain it.
    • It's rather trivial to write a resource dump into your code. I have one built into mine. This is an easy way to just quickly get everything back out of it.
    • Note that resource file names are always upper-case with no white space. However, the LoadResData function will take care of this for you. However, this can be a bit of a problem if you use the EnumResourceNames API call. I'll let you sort that one out.
    • And yes, ActiveX.dll files can also contain resource files. In fact, I've got ActiveX.dll files in the resources of my main project. And, these also have resources. So, I suppose I have nested resources.


    That's about it I suppose.

    Good Luck,
    Elroy

    EDIT1: Ohhh, I like dz32's idea. I just saw that. If I were managing 1000s of images for some reason, that might be precisely how I'd do it.

    EDIT2: Also, if you spend a bit of time with it, you could learn about the resource compiler (RC.EXE). You can feed it a directive file on the command line which will tell it to create a .RES file out of any number of files you like. It's not going to compress them, but it will combine them. And then you can use that .RES file with your VB6 project.
    LaVolpe is another user here in the forum?

  10. #10
    Fanatic Member
    Join Date
    Aug 2013
    Posts
    806

    Re: Is there a way to work around the Resource Editor?

    Hi Schnel. Here are two links to get you started with the standalone resource compiler.

    First, an "old but good" introduction for VB6 users, c/o vbaccelerator:

    http://www.vbaccelerator.com/home/VB...E/article.html

    And of course, MSDN has comprehensive documentation on the newest version of rc.exe:

    https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

    It's basically as simple as creating an ".rc" file, which is just a text document describing what resources you want to include, then compiling that ".rc" file into an actual ".res" file using rc.exe. Any file that you want included as plain binary data could be described using a line like:

    Code:
    ResourceName  CUSTOM  resource_filename.jpg
    You can use another identifier, if you want. I use "CUSTOM" to help me remember that this is a custom-included file, not a standard resource type.

    After compiling your resource file, you can then load that resource using code like this:

    Code:
    Dim fileBytes() As Byte
    fileBytes = LoadResData("ResourceName", "CUSTOM")
    That will give you the exact original file, stored inside a byte array. You can then write the bytes out to a temp file, or process them directly in memory. Whatever you prefer.

    Quote Originally Posted by dilettante
    Ahh, but it isn't VB6. It relies on runtime injection of some compiled C or something. Just the thing to trigger antivirus flags, and as far as I can recall it doesn't credit the source and may be breaking an open source license.
    dilettante, you've turned into the "boy who cried wolf" when it comes to code theft. It took all of two seconds to click into wqweto's repository, and right there in the /lib subfolder is the original C source with the same license (MIT) specified right in the header, as you'd expect.

    Code theft is a serious accusation. Stop making it every time you're too lazy to click a link.
    Check out PhotoDemon, a pro-grade photo editor written completely in VB6. (Full source available at GitHub.)

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Jul 2015
    Posts
    24

    Re: Is there a way to work around the Resource Editor?

    Quote Originally Posted by Tanner_H View Post
    Hi Schnel. Here are two links to get you started with the standalone resource compiler.

    First, an "old but good" introduction for VB6 users, c/o vbaccelerator:

    http://www.vbaccelerator.com/home/VB...E/article.html

    And of course, MSDN has comprehensive documentation on the newest version of rc.exe:

    https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

    It's basically as simple as creating an ".rc" file, which is just a text document describing what resources you want to include, then compiling that ".rc" file into an actual ".res" file using rc.exe. Any file that you want included as plain binary data could be described using a line like:

    Code:
    ResourceName  CUSTOM  resource_filename.jpg
    You can use another identifier, if you want. I use "CUSTOM" to help me remember that this is a custom-included file, not a standard resource type.

    After compiling your resource file, you can then load that resource using code like this:

    Code:
    Dim fileBytes() As Byte
    fileBytes = LoadResData("ResourceName", "CUSTOM")
    That will give you the exact original file, stored inside a byte array. You can then write the bytes out to a temp file, or process them directly in memory. Whatever you prefer.



    dilettante, you've turned into the "boy who cried wolf" when it comes to code theft. It took all of two seconds to click into wqweto's repository, and right there in the /lib subfolder is the original C source with the same license (MIT) specified right in the header, as you'd expect.

    Code theft is a serious accusation. Stop making it every time you're too lazy to click a link.
    Thanks. I'll give this a try. Where can I actually download the compiler? I tried googling it but only found MSDN documentation for it.

  12. #12
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: Is there a way to work around the Resource Editor?

    Quote Originally Posted by schnel View Post
    Thanks. I'll give this a try. Where can I actually download the compiler? I tried googling it but only found MSDN documentation for it.
    it should be included with any copy of visual studio or visual c++, or platform sdk or ddk.

  13. #13
    Fanatic Member
    Join Date
    Aug 2013
    Posts
    806

    Re: Is there a way to work around the Resource Editor?

    Quote Originally Posted by schnel View Post
    Thanks. I'll give this a try. Where can I actually download the compiler? I tried googling it but only found MSDN documentation for it.
    You may be able to find it just by searching your hard drive for "rc.exe" (any number of Visual Studio downloads may include it). You can also download the latest free Visual Studio Community Edition to get an up-to-date copy.

    Finally, if you're more of an open-source person, there's an open-source replacement called "GoRC" that uses identical syntax to the Microsoft version, but is freely distributable. Here's a link to its homepage:

    http://godevtool.com/#rc
    Check out PhotoDemon, a pro-grade photo editor written completely in VB6. (Full source available at GitHub.)

  14. #14
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: Is there a way to work around the Resource Editor?

    Quote Originally Posted by Tanner_H View Post
    You may be able to find it just by searching your hard drive for "rc.exe" (any number of Visual Studio downloads may include it).
    I think I have about 7 copies on my dev image.

    also not to give dil too much credit - but a copy of the putty license/attribution is missing from wqweto's ZipArchive.

    https://www.chiark.greenend.org.uk/~...y/licence.html

    It should look like this.

    Code:
    PuTTY is copyright 1997-2017 Simon Tatham.
    
    Portions copyright Robert de Bath, Joris van Rantwijk, Delian Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry, Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, Markus Kuhn, Colin Watson, Christopher Staite, and CORE SDI S.A.
    
    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
    
    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    Last edited by DEXWERX; Jun 8th, 2017 at 09:35 AM.

  15. #15
    Fanatic Member
    Join Date
    Aug 2013
    Posts
    806

    Re: Is there a way to work around the Resource Editor?

    Quote Originally Posted by DEXWERX View Post
    also not to give dil too much credit - but a copy of the putty license is missing from wqweto's ZipArchive.
    A great suggestion to include it, and certainly a nice courtesy - but I'm not sure that MIT requires it, given that wqweto has literally included an *exact* copy of the original source file, with all comments intact.

    It's this line from the license:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
    IMO it's always good to err on the side of caution, but I'm not sure that one file out of the 50+ in the original constitutes a "substantial portion" of the original software. (That clause is a frequent source of confusion, though like I said, I personally like the advice to always include the license, regardless, "just in case".)

    Even better would be the PuTTY team explicitly stating licensing terms and copyright in each source file... then no one would have to worry about this!

    (/unqualified opinion: This is one of the reasons I personally prefer BSD-style licenses, as they explicitly clarify this.)
    Check out PhotoDemon, a pro-grade photo editor written completely in VB6. (Full source available at GitHub.)

  16. #16

    Thread Starter
    Junior Member
    Join Date
    Jul 2015
    Posts
    24

    Re: Is there a way to work around the Resource Editor?

    Quote Originally Posted by Tanner_H View Post
    You may be able to find it just by searching your hard drive for "rc.exe" (any number of Visual Studio downloads may include it). You can also download the latest free Visual Studio Community Edition to get an up-to-date copy.

    Finally, if you're more of an open-source person, there's an open-source replacement called "GoRC" that uses identical syntax to the Microsoft version, but is freely distributable. Here's a link to its homepage:

    http://godevtool.com/#rc
    Got it, thanks.

  17. #17
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,805

    Re: Is there a way to work around the Resource Editor?

    Hi schnel,

    It seems that you're getting plenty (possibly too much) advice. I'm glad you found the little RC.EXE program, and figured out that it's a Microsoft program. You can feed it little scripts with lists of your files, and it'll make a .RES file for you. Those scripts are a bit difficult to figure out at first, but not terribly bad. There are a couple of web pages around that describe how to set them up, but I'll let you Google for them.

    And yes, LaVolpe is another member of the forums. I'm a bit shocked that he hasn't chimed in on this thread. He is also quite knowledgeable about these .RES files.

    Regarding wqweto's unzipper, it is a pure VB6 solution. I've attached the class that I use in my program to do this type of unzipping.

    It seems that you now have lots of options.

    Best of luck with it,
    Elroy

    EDIT1: Here's a down-and-dirty how to use it.

    Code:
        Dim oUnZip As Class1
        Set oUnZip = New Class1
        oUnZip.Init App.path & "\ZipFile.zip"
        oUnZip.Unzip App.path
        Set oUnZip = Nothing
    Also, if you want to declare your object at the module level and "WithEvents", there are some events it'll fire to let you know when it's done.

    Note that this does assume that you've already extracted your ZIP file from your resources.
    Attached Files Attached Files
    Last edited by Elroy; Jun 8th, 2017 at 05:08 PM.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  18. #18

    Thread Starter
    Junior Member
    Join Date
    Jul 2015
    Posts
    24

    Re: Is there a way to work around the Resource Editor?

    Quote Originally Posted by Elroy View Post
    Hi schnel,

    It seems that you're getting plenty (possibly too much) advice. I'm glad you found the little RC.EXE program, and figured out that it's a Microsoft program. You can feed it little scripts with lists of your files, and it'll make a .RES file for you. Those scripts are a bit difficult to figure out at first, but not terribly bad. There are a couple of web pages around that describe how to set them up, but I'll let you Google for them.

    And yes, LaVolpe is another member of the forums. I'm a bit shocked that he hasn't chimed in on this thread. He is also quite knowledgeable about these .RES files.

    Regarding wqweto's unzipper, it is a pure VB6 solution. I've attached the class that I use in my program to do this type of unzipping.

    It seems that you now have lots of options.

    Best of luck with it,
    Elroy

    EDIT1: Here's a down-and-dirty how to use it.

    Code:
        Dim oUnZip As Class1
        Set oUnZip = New Class1
        oUnZip.Init App.path & "\ZipFile.zip"
        oUnZip.Unzip App.path
        Set oUnZip = Nothing
    Also, if you want to declare your object at the module level and "WithEvents", there are some events it'll fire to let you know when it's done.

    Note that this does assume that you've already extracted your ZIP file from your resources.
    I appreciate that, Elroy.

  19. #19
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,467

    Re: Is there a way to work around the Resource Editor?

    Ok, decide to chime in -- sheesh can't even take a week or so off?

    Using rc.exe might be a solution for now and once one becomes more comfortable with it, may even prefer it over VB's res editor. VB's editor does have a re-numbering option but only applies to the string tables. Unfortunately, VB's editor only allows you to tweak one resource at a time, so if dealing with dozens or even hundreds -- it will be a PITA. If one was really fluent in parsing/writing resource files (not volunteering here), a small script can be created to parse & re-number/re-name blocks of resources.

    Glad I happened on this posting, for purely personal reasons. As it just happens, I am writing something I may offer as a suitable substitute for VB's res editor. I'm already address some known issues/limitations with VB, but am interested in others. Haven't considered a bulk upload prior to this thread, but am now.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  20. #20
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: Is there a way to work around the Resource Editor?

    I'm glad someone is writing a replacement add-in - it's a great project idea that's really not that difficult and would help out the community immensely.

  21. #21
    Frenzied Member wqweto's Avatar
    Join Date
    May 2011
    Posts
    1,585

    Re: Is there a way to work around the Resource Editor?

    Quote Originally Posted by DEXWERX View Post
    . . . a copy of the putty license/attribution is missing from wqweto's ZipArchive.
    Yes, this attribution is missing indeed (out of hurrying up to ship working version). Of course it's better to be included, fixed in 6680e2.

    On a side note: `cZipArchive` can decompress straight from `LockResource` memory pointer to a byte array or a string but will need a (fairly short) custom VFS adapter implementation for this. This is 100% the use-case I currently use it in my projects. Will try to enhance it for the next release so in addition to filenames, methods to be able to operate on raw memory pointers too.

    cheers,
    </wqw>

  22. #22
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,805

    Re: Is there a way to work around the Resource Editor?

    @LaVolpe: Yes, I'll add my vote to a replacement for the VB6 Resource Editor Add-in. Also, it'd be super cool if it was a pure VB6 solution. In other words, if it circumvented RC.EXE as well as the add-in, that would be awesome.

    This is something I've often thought of doing, but just never taken the time. And there are quite a few references out there on the internal structure of these things:

    https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
    http://ffenc.blogspot.com/2008/04/wi...res-files.html
    http://bytepointer.com/resources/win32_res_format.htm
    http://www.moon-soft.com/program/FOR...nary/res32.htm


    And I'm sure there are others. I've even got some saved in my junk drawer folder.

    Best Regards,
    Elroy
    Last edited by Elroy; Jun 12th, 2017 at 10:27 AM.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  23. #23
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: Is there a way to work around the Resource Editor?

    Personally I would just make a GUI to automate RC.

  24. #24
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    18,467

    Re: Is there a way to work around the Resource Editor?

    Quote Originally Posted by Elroy View Post
    @LaVolpe: Yes, I'll add my vote to a replacement for the VB6 Resource Editor Add-in. Also, it'd be super cool if it was a pure VB6 solution. In other words, if it circumvented RC.EXE as well as the add-in, that would be awesome.

    This is something I've often thought of doing, but just never taken the time. And there are quite a few references out there on the internal structure of these things:
    Thanx for the links, I'll look them over. I am 100% comfortable with parsing the res file and writing it by hand, including the string table(s). Still much to do, but trying to find links to help identify what is valid for specific resource types is nearly an impossible task. For example, good luck finding definitive information on RT_FONTDIR. Even rc.exe (depending on version) does it differently. Granted, that is an archaic resource type (back in the Win3.1 days) and I'm not too worried about it. That specific type would be recognized/parsed, but I will not allow creation or renaming of items in that res type. Probably a bad example since fonts should probably be placed in "CUSTOM" res type and bytes sent to APIs for registering/usage. But when it comes down to it, if the user wants to place a TIFF in RT_HTML for example, probably nothing technically wrong. Was just thinking it would be a good idea to minimally verify data for the 20+ res types. Some res types are no-brainers for verification: RT_BITMAP, RT_ICON/CURSOR & its GROUP, RT_MANIFEST are among some easy to validate. Trying to make it more user-friendly also, dragging & dropping from the right pane to the tree pane for example. Still gonna restrict naming of items to uppercase ANSI so they are API-friendly & VB won't reject the file when trying to add it to a project -- if VB won't take it, good luck getting it compiled into your project even if the resource file is correctly formatted.

    As it stands now, the editor is a non-add-in. When I get it "done", I'll be posting for a bit of advice on creating an add-in for it. Never done an add-in. I'd like it to activate when user double clicks on the res file in the VB explorer tree and optionally load separately from a menu, like ApiViewer2004 (if you've opted for its add-in)

    Sneak peek, but will try to refrain from talking about this project on the OP's thread.
    Name:  Untitled.png
Views: 569
Size:  8.2 KB

    Personally I would just make a GUI to automate RC.
    If a GUI allows selecting files, or otherwise creating resource items, don't see the advantage. Just write the resource file vs generating scripts and/or spawning an RC instance. Res files are actually very easy to write. The only files I've written that are rejected by VB are due to usage of unicode names and inclusion of characters VB refuses to accept, i.e., the @ symbol. Of course, VB's res editor has other issues displaying valid resources, like those that contain 32 bit icons; even though that doesn't stop VB from adding it to a project
    Last edited by LaVolpe; Jun 12th, 2017 at 02:06 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  25. #25
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,661

    Re: Is there a way to work around the Resource Editor?

    Found another unusual option.

    While a Jet MDB might make a lot of sense, the Jet 4.0 OLEDB Provider can also use its dBase 5.0 Installable ISAM. This supports OLEOBJECT type columns.

    That way you could store pictures in a naked .DBF file along with its BLOB resource .DBT file. This could have indexes or not, but that means additional files.

    The .DBF + .DBT file are not much larger in size than the Original image files along with any other data like a name, type, ID, etc. These can be smaller than a single Jet MDB with the same data. Any CHAR fields are almost certainly limited to ANSI/DBCS characters, but that is seldom an issue for real applications.


    If you have a dBase 7.x OLEDB Provider or a later VFP Provider installed you can use those instead to do the same thing and get Unicode support as well. The downside is that adds a deployment issue.

    There are other options like SQLite but those come with their own deployment headaches, and many of them are "broken" and corrupt BLOB data. The "world is text" to them and they love to blindly treat any string of bytes as text and convert it to UTF-8. Then they either fail to convert back, or doing so produces the data corruption.

    Anything that has SQLite statically linked is a servicing nightmare too. As new bugs come up you have to obtain an updated "wrapper" library and deploy it to all clients.

  26. #26
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,805

    Re: Is there a way to work around the Resource Editor?

    Say LaVolpe. Please please please always give us a Stand-Alone option if/when you get this going. Other than having to possibly reload our VBP project (and I'm not even entirely sure about that one), I see no advantages of having this as an Add-In.

    Best,
    Elroy

    EDIT1: And there's one rather large downside. If an Add-In crashes, it has the potential for crashing the IDE, which could cause us to lose unsaved work.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  27. #27
    Addicted Member
    Join Date
    Nov 2011
    Posts
    130

    Re: Is there a way to work around the Resource Editor?

    Quote Originally Posted by LaVolpe View Post
    Thanx for the links, I'll look them over. I am 100% comfortable with parsing the res file and writing it by hand, including the string table(s). Still much to do, but trying to find links to help identify what is valid for specific resource types is nearly an impossible task. For example, good luck finding definitive information on RT_FONTDIR. Even rc.exe (depending on version) does it differently. Granted, that is an archaic resource type (back in the Win3.1 days) and I'm not too worried about it. That specific type would be recognized/parsed, but I will not allow creation or renaming of items in that res type. Probably a bad example since fonts should probably be placed in "CUSTOM" res type and bytes sent to APIs for registering/usage. But when it comes down to it, if the user wants to place a TIFF in RT_HTML for example, probably nothing technically wrong. Was just thinking it would be a good idea to minimally verify data for the 20+ res types. Some res types are no-brainers for verification: RT_BITMAP, RT_ICON/CURSOR & its GROUP, RT_MANIFEST are among some easy to validate. Trying to make it more user-friendly also, dragging & dropping from the right pane to the tree pane for example. Still gonna restrict naming of items to uppercase ANSI so they are API-friendly & VB won't reject the file when trying to add it to a project -- if VB won't take it, good luck getting it compiled into your project even if the resource file is correctly formatted.

    As it stands now, the editor is a non-add-in. When I get it "done", I'll be posting for a bit of advice on creating an add-in for it. Never done an add-in. I'd like it to activate when user double clicks on the res file in the VB explorer tree and optionally load separately from a menu, like ApiViewer2004 (if you've opted for its add-in)

    Sneak peek, but will try to refrain from talking about this project on the OP's thread.
    Name:  Untitled.png
Views: 569
Size:  8.2 KB


    If a GUI allows selecting files, or otherwise creating resource items, don't see the advantage. Just write the resource file vs generating scripts and/or spawning an RC instance. Res files are actually very easy to write. The only files I've written that are rejected by VB are due to usage of unicode names and inclusion of characters VB refuses to accept, i.e., the @ symbol. Of course, VB's res editor has other issues displaying valid resources, like those that contain 32 bit icons; even though that doesn't stop VB from adding it to a project
    Hi LaVolpe
    Did you ever make a Resource Editor for VB6. would be greatful for download link.

    k_zeon

  28. #28
    Junior Member
    Join Date
    Dec 2016
    Posts
    20

    Re: Is there a way to work around the Resource Editor?

    Interesting to see other techniques.
    Since years i use a complete different approach.

    I have written myself a MS Excel "Frontend" to manage fast all kind of resources (Text and "Media" - Data) -> table based.
    This WB allows me to save all resources into a VB6 propertybag.
    Benefit of a propertybag -> each item is fitted with a unique key and you load/save it fast via oBag.Contents

    My actual resource file contains only the mandatory application icon / manifest and this "blob" resource file (which contains actually the single resources).
    The '.res' - is compiled via rc.exe

    Within my apps i just restore the bytedata back into a property bag and can access fast each resource (even with pre cache)
    Why: easy to manage and it's not so easy for the resource thiefs out there to steal or modify the data.

    Code:
     Dim oBag As PropertyBag
     dim bData() as byte
      
     bData = oBag.Contents	'get the content of a PropertyBag into a byte array (allow you to save this into a file)
     or
     bData = LoadResData(ResName, ResType)
     Set oBag = New PropertyBag
     oBag.Contents = bData	'restore the propertybag

  29. #29
    Addicted Member
    Join Date
    Nov 2011
    Posts
    130

    Re: Is there a way to work around the Resource Editor?

    Quote Originally Posted by Gusto View Post
    Interesting to see other techniques.
    Since years i use a complete different approach.

    I have written myself a MS Excel "Frontend" to manage fast all kind of resources (Text and "Media" - Data) -> table based.
    This WB allows me to save all resources into a VB6 propertybag.
    Benefit of a propertybag -> each item is fitted with a unique key and you load/save it fast via oBag.Contents

    My actual resource file contains only the mandatory application icon / manifest and this "blob" resource file (which contains actually the single resources).
    The '.res' - is compiled via rc.exe

    Within my apps i just restore the bytedata back into a property bag and can access fast each resource (even with pre cache)
    Why: easy to manage and it's not so easy for the resource thiefs out there to steal or modify the data.

    Code:
     Dim oBag As PropertyBag
     dim bData() as byte
      
     bData = oBag.Contents	'get the content of a PropertyBag into a byte array (allow you to save this into a file)
     or
     bData = LoadResData(ResName, ResType)
     Set oBag = New PropertyBag
     oBag.Contents = bData	'restore the propertybag
    Hi Gusto.

    Thanks for this, i did not think about using PropertyBags like this instead of resources.
    coming away from resource file etc.

    If i wanted to use this as a container to hold data, how would i use it to hold zip file & pictures, if i wanted to add
    an unknown qty of each.

    At present i have created my own file container and manage it. But as someone pointed out its quite difficult to add
    new functionality. But using probags seems quite a bit easier.

    I hold Text, VB code, Images. but want to add zip files within container file.
    How would i write code to hold multiple files & images of unknown qty.

    thanks

    k_zeon

  30. #30
    Junior Member
    Join Date
    Dec 2016
    Posts
    20

    Re: Is there a way to work around the Resource Editor?

    Sorry for the delayed feedback and that i cant share the entire project since this code is bound with a (none public) class frame work.
    But i can share the relevant sub parts.

    i guess we are all aware that base64 decoding costs some time and increase the filesize up to 40%.
    For MS Excel Workbooks i still use XML which is saved diretly within the workbook.
    For VB6 i create a propertybag and compile this into a .RES file.

    Quick limitations of a propertrybag.
    a) (as far i know) you cant extract all available "PropertyNames". (not even with some copymemory hacks which work for collections)
    You can work with fixed incremented names (Like: item1, item2, ..) or work with a fixed helper (which contain the keynames)
    i work with
    item{counter}_Key <- which contain the real key of the resource
    item{counter}_Data <- which contain the byte() of the resource

    b) you can save byte arrays .. but not other type of arrays. (without a custom conversion into a byte array)

    In order to get the FileData into a byte array:
    Code:
     Dim iFile As Long
     iFile = FreeFile
     
     'do some checks that the file exists ..  
     Open sFilePath For Binary Access Read As iFile    'zero length file content will raise error 9
      ReDim bData(0 To LOF(iFile) - 1&) As Byte
      Get iFile, , bData
     Close iFile
    in order to feed / save a propertybag you can:
    Code:
     dim oBag as new PropertyBag
     oBag.WriteProperty "item1_key", "add here a key"
     oBag.WriteProperty "item1_data", bData()	'<- the byte data of the resfile
    
     '.. once done - get content of the bag and save it
     bData = oBag.Contents
     sFile = "somepath\data.bag"
     Open sFile For Binary Access Write As #1
      Put #1, , bData
     Close #1
    in order to compile this into a res file you need
    a) a textfile (like Basis.RC)
    content could be:
    LANGUAGE 0,0
    0 ICON \AppIcon.ico
    blob CUSTOM \data.bag

    b) you need RC.EXE to compile the .rc into a .res
    location is %PROGRAMFILES%\Microsoft Visual Studio\VB98\Wizards\RC.EXE
    batch structure to compile:

    @ECHO OFF
    SET RCEXE=%PROGRAMFILES%\Microsoft Visual Studio\VB98\Wizards\RC.EXE
    SET MAINDIR=%~dp0
    SET SOURCEFILE=Basis.rc
    SET TARGETFILE=Basis.res

    if exist "%MAINDIR%%TARGETFILE%" del "%MAINDIR%%TARGETFILE%"
    "%RCEXE%" /r /w /fo "%MAINDIR%%TARGETFILE%" "%MAINDIR%%SOURCEFILE%"

    Once you link the .Res file with your project you can access the 'custom' resource "blob' which will return a byte array.
    This byte array could be moved again into a propertybag and you can access the items

    Code:
    dim oBag as new PropertyBag
    oBag.Contents = LoadResData("custom","blob")
    Key1 = oBag.ReadProperty("item1_key")
    Within the project i 'cache' the data into collections in order to access them faster.
    (one for FileData .. one for stringtables)

    For FileData i use currently
    item{counter}_Key
    item{counter}_Data
    item{counter}_MimeType
    item{counter}_PreLoad <- used for images to pre cache them | once False i just cache the Key

    For Text(StringTable) i use currently
    text{counter}_Key
    item{counter}_LCID0
    item{counter}_LCID1039
    item{counter}_LCID{n}

    Excel is just used to maintain table based the files and textdata which could be addressed later via the unique key.
    I don't like the Res-Editor and this allows me to quick maintain the data (outside a rc file) and the sub items cant be so easy extracted with resource explorer API's.

  31. #31
    Hyperactive Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    294

    Re: Is there a way to work around the Resource Editor?

    Haven't read the entire thread but I use Resource Builder v3. I looked long and hard for a resource file editor which worked with VB6 resource files and supported images and internationalization. It's not free but works very well.

    http://www.resource-builder.com/

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width