Solved

Resource File Problem

Posted on 1998-11-04
6
162 Views
Last Modified: 2010-04-04
I have a app that gets strings from a resource file.  The app downloads a new resource file and copies it over the old.  teh next time the app gets started, it should read from the new resource file, but it seems to still read from the old file.  Do I need to free the resource file?  Is the resource file call case sensitive?  Please help...
0
Comment
Question by:MichaelB98
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 4

Expert Comment

by:dwwang
ID: 1345683
A resource file is built into the exe, so if you load resources from it, it will always be the "old" ones.

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1345684
Oh, is that what you had in mind??? As dwwang said the RES file is build into the EXE file and even if you supply the res file it doesn't read from it... You need to use LoadResource() or whatever that is,.. It's not that easy to do what you want.... I'll try to think and probably tell you what I got tomorrow,,, You cannot free a resouce since it's freed by itself.

Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:Lischke
ID: 1345685
What about creating a resource DLL? Just create an empty DLL project and include your resources there. In your application you can use LoadLibrary (which hasn't necessarily to have the DLL extension) to load it. This call will return a HInstance handle, which you can use in LoadString to actually load the string. By replacing this resource DLL you can update all strings (this works also very well for other resources too, like icons, bitmaps and the like, but with different calls to load them).

procedure TMainForm.LoadRes(FileName: String);

var Handle: HInst;
    Buffer : array[0..255] of Char;

begin
  Handle:=LoadLibrary(FileName);
  if Handle > 0 then
  begin
    LoadString(Handle,ResIDOfString,Buffer,SizeOf(Buffer));
    StringList.Add(Buffer);
  end;
  FreeLibrary(Handle);
end;

See also LoadMenu, LoadBitmap, LoadAccelerator, LoadResource etc. for other types of resources.

Ciao, Mike
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:MichaelB98
ID: 1345686
My simplest solution I guess is to make it read from an ini file instead.  The onlt problwm with the dll idea, is I am letting someone make the updates for the app and now they have to have a copy of Delphi ( or another language ) AND know how to use it.  I was hoping for something easy.

Michael
0
 

Accepted Solution

by:
jerrypsl earned 100 total points
ID: 1345687
Resource file is linked to the executable when you build your project, thus you need to
do a full rebuild if you change your resource contents later. In D4, go to Project menu then
click on Build All Projects, for D3 i think it's something like "Rebuild Project" (not sure).

Q: After I made a change to my resource file, I pressed F9 to recompile my project, but why the application still using the old resource instead of the new one?
Ans: Although you press F9 after you change your resource contents to recompile the project, the .exe will still contain the old resources because the compiler detects no changes in your source code and thus just run the .exe without rebuilding it.

0
 
LVL 10

Expert Comment

by:Lischke
ID: 1345688
Ooops, you didn't say that some third party will create your resources. I was assuming that you are the only one who's changing them. And you have indeed a Delphi copy since you have developed the application.

For simple string updates a plain text file may do it, but for other resources you will have to find an more complex solution (like separate files for each resource type etc.).

Creating a resource DLL which contains any type of resources which are in res files is so easy, you could do that in a few minutes.

Ciao, Mike
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

756 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