Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

pack a file...

Posted on 2003-11-08
3
Medium Priority
?
214 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 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

670 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