Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

pack a file...

Posted on 2003-11-08
3
Medium Priority
?
219 Views
Last Modified: 2010-04-05
how can i pack a file within my application and on button click extract it to a certain path and run it (and close my app.)....
I have a screensaver that would like to send to a friend but she does not now how to put it into C:\Windows\System32
and run it ...
So I tought to send her an app to do it for her.
(windmill.scr)
Help appreciated...
Is it possible to use rxlib file storage thing ?
0
Comment
Question by:senad
  • 2
3 Comments
 

Expert Comment

by:Karamja
ID: 9708397
Hello,

Making RC File:
In notepad,
ScreenSaver RCDATA "FullPathToScreenSaver"
Save As ScreenSaver.rc
------
.RC To .RES:
In run box type,
Brcc32 "PathToRCFile"
------
In Project:

Var
ResStream : TResourceStream;
FileStream : TFileStream;

{$r ScreenSaver.RES}

Add this to button to unpack screensaver,

ResStream := TResourceStream.Create(0, 'ScreenSaver', RT_RCDATA);
try
FileStream := TFileStream.Create('C:\Windows\System32\windmill.scr', fmCreate);
try
FileStream.CopyFrom(ResStream, 0);
finally
FileStream.Free;
end;
finally
ResStream.Free;
end;
0
 
LVL 2

Expert Comment

by:SaLz
ID: 9710164
Make a Folder Called RC in "C:\RC\"

Put the file you are wanting to add into your program for extraction.

for example, you put a image in the folder, called home.jpg

now once you have put your file into the folder, open up a notepad.

in the notepad type this in.

HOME RCDATA "C:\rc\home.jpg"

now save as any name you want, call it home.rc but make sure you rename the txt file as .rc
home.txt should be home.rc

Now Open up Command Prompt.
Type "brcc32 C:\RC\home.rc" (with out brackets)
Press Enter...
Now it has complied you the res as home.res.

Now Move the home.res to your projects folder.

Now open your project,
where you see {$R *.dfm} put your home.res below that like this

{$R *.dfm}
{$R home.res}

now when you compile your project it will me inside your exe, now you want to extract it to a location.

procedure TForm1.Button1Click(Sender: TObject);
begin
ResStream := TResourceStream.Create(0, 'Details', RT_RCDATA);
try
FileStream := TFileStream.Create('C:\rc\HomeExtracted.txt', fmCreate);
try
FileStream.CopyFrom(ResStream, 0);
finally
FileStream.Free;
end;
finally
ResStream.Free;
end;
end;
0
 
LVL 2

Accepted Solution

by:
SaLz earned 1000 total points
ID: 9710174
it should be home than details my bad english.

procedure TForm1.Button1Click(Sender: TObject);
begin
ResStream := TResourceStream.Create(0, 'home', RT_RCDATA);
try
FileStream := TFileStream.Create('C:\rc\HomeExtracted.jpg', fmCreate);
try
FileStream.CopyFrom(ResStream, 0);
finally
FileStream.Free;
end;
finally
ResStream.Free;
end;
end;
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

783 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