Solved

pack a file...

Posted on 2003-11-08
3
196 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 250 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 303
how to center only a line in richedit? 4 57
drawing animated level bar based on numbers 3 97
How to build JSON File in Delphi 6 3 34
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…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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