Solved

Loading Custom Resources

Posted on 1998-03-04
7
151 Views
Last Modified: 2010-04-06
I want to load custom resources into a TMemoryStream. I have made a *.RES file with custom data types (using Borland Workshop).  But my app keeps saying "Resource not found error". I am trying to load it with the command

FCompressedStream := TResourceStream.Create(HInstance, ResName, RT_RCDATA);

---------------------
Extra info
---------------------
I'm using D3 and Win95.

The custom resource happens to be a compressed bitmap. (Yes, I really really do want to compress it - it makes my EXE infinitly smaller and then I decompress it once only at run time).
0
Comment
Question by:WarrenYoungEdinburgh
  • 3
  • 2
  • 2
7 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360075
Hi,

have you added the following in the compiler directive in the implementation
               section of your unit. {$R ResourceFilename} ?

Regards, zif.

0
 

Author Comment

by:WarrenYoungEdinburgh
ID: 1360076
Yes I have added that, with the .res on the end of the filename.
0
 

Author Comment

by:WarrenYoungEdinburgh
ID: 1360077
Judging from the size of the EXE file, it is clear that the resource file is being included in the EXE.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 8

Expert Comment

by:ZifNab
ID: 1360078
strange,

What about ...., PCHAR(RT_RCDATA);
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1360079
Try also:
  MyResStr := TResourceStream.Create(hInstance, PChar('#123'), PChar('MYSECTION'));
where MYSECTION is the resource group that you have put your resource 123 in.

I wrote the following function, and have used it several times to save a resource to disk:

function ExtractFileFromRes(hLib: Integer; const Filename, ResType, ResName: string): Boolean;
// E.g. ExtractFileFromRes(hInstance, 'C:\Test.exe', 'CUSTOM', '#123');
var
  rs: TResourceStream;
begin
  Result := True;
  try
    rs := TResourceStream.Create(hLib, PChar(ResName), PChar(ResType));
    try
      rs.SaveToFile(Filename);
    finally
      rs.Free;
    end;
  except
    Result := False;
  end;
end;

JB
0
 

Author Comment

by:WarrenYoungEdinburgh
ID: 1360080
Thank you Jim Bob. That solved it. The trick was how to utilise a custom resource type.

Thanks very much.
Warren.
0
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 100 total points
ID: 1360081
Glad it worked.  I assume that I can answer the question then?

JB
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 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

10 Experts available now in Live!

Get 1:1 Help Now