[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

External vs. internal resources, bitmaps, .EXE size etc.

Posted on 2005-04-13
6
Medium Priority
?
232 Views
Last Modified: 2013-11-20
My application currently is an EXE and no external DLL's or anything, pretty simple as far as file structure is concerned. I do however have a bunch of external 24bit bitmap files that are used to build various parts of the user interface, and at this time, I have imported them all into my resource file and when the application compiles, the resulting .EXE is around 6MB.. This I know is going to grow as additional bitmaps are imported in to support UI that I have not yet put in place.

What are my alternatives?  I load the images like this:

  HINSTANCE hInstResource = AfxFindResourceHandle(MAKEINTRESOURCE(IDB_BITMAPX), RT_BITMAP);
  hBmp = (HBITMAP)::LoadImage(hInstResource, MAKEINTRESOURCE(IDB_BITMAPX), IMAGE_BITMAP, 0, 0, 0);

Everything is working just fine, I'm just concerned that a large EXE might be problematic in the end? I could of course just load the files, and have the bitmaps existing along with the EXE, but I don't want straight-up bitmap files in the application folder, that could be edited or accidentally deleted and what not. Can they be packaged somehow into a DLL or an external resource file?

What do you suggest?

Thanks!
-Paul
0
Comment
Question by:PMH4514
  • 3
  • 3
6 Comments
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 13775163
Any external files could be edited/deleted.  
You could package them in resource dll's and load from those.
However this hack might work.  Have the bitmaps as external files but rename them eg x001.dll, x002.dll and so on.  Now just load them as you would a normal bitmap from an external file.
0
 

Author Comment

by:PMH4514
ID: 13775443
hacks are always nice :)

how would I go about packaging them in resource dll's?
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 13779456
Make a regular dll.
Put the bitmaps into that as you currently do.
Then when you want a bitmap the code is roughly

HINSTANCE hInst = LoadLibrary("bitmaps.dll");
if(hInst)
{
  hBmp = (HBITMAP)::LoadImage(hInst, MAKEINTRESOURCE(IDB_BITMAPX), IMAGE_BITMAP, 0, 0, 0);
  FreeLibrary(hInst);
}
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:PMH4514
ID: 13780306
oh so it's just a DLL project with the bitmaps as resources.. looks easy enough, I'll give that a try.

Is there a reason to avoid a large .EXE by putting them in the DLL though or does it not really matter? (ie. the bitmaps will get loaded anyway)
0
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 200 total points
ID: 13780499
If you have a number of resource dll's then there may be a 'slight' performance gain at startup.  Load exe - 100KB then first resource dll - further 250KB - compared to load exe 20MB.  With multiple resource dll's only the ones required get loaded and then only when required.  A monolithic app has to be read from disk even if a lot isn't going to be of use (I think)

The main advantage of resource dll's is that they can be language/country dependant.  Same code, same ID but different text/pictures depending on LoadLibrary("CountryA.dll") or LoadLibrary("CountryB.dll")
You can even go further and just have LoadLibrary("resource.dll") and when you install the product it copies and renames the appropriate dll.
0
 

Author Comment

by:PMH4514
ID: 13781447
Sounds good. Thanks!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

872 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