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

x
?
Solved

Resource File Problem

Posted on 1998-11-04
6
Medium Priority
?
168 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
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 200 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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 anti-spam), the admin…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

873 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