Solved

Resource File Problem

Posted on 1998-11-04
6
155 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now