?
Solved

Resource File Problem

Posted on 1998-11-04
6
Medium Priority
?
166 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 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