Solved

pack a file...

Posted on 2003-11-08
3
210 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
[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
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month4 days, 5 hours left to enroll

630 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