Thread View: alt.comp.borland-delphi
8 messages
8 total messages
Started by 0BIT
Thu, 24 Jul 2003 19:54
Including in .exe
Author: 0BIT
Date: Thu, 24 Jul 2003 19:54
Date: Thu, 24 Jul 2003 19:54
43 lines
2417 bytes
2417 bytes
I have a program written for D6 and compiled it.
After compilation I want to add a .txt file into the .exe...
Then read with my program the added .txt file and put it into the memo...
How do I do this?
Greetings,
0BIT
unit P1_Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormShow(Sender: TObject);
begin
Memo1.Realign;
end;
{SOMEWHERE I SHOULD READ THE .TXT FILE INTO THE MEMO ???}
end.
Re: Including in .exe
Author: Tom de Neef
Date: Thu, 24 Jul 2003 20:54
Date: Thu, 24 Jul 2003 20:54
55 lines
2984 bytes
2984 bytes
"0BIT" <someone@123.com> wrote in message
news:fQWTa.616794$V9.49538640@amsnews02.chello.com...
> I have a program written for D6 and compiled it.
> After compilation I want to add a .txt file into the .exe...
> Then read with my program the added .txt file and put it into the memo...
> How do I do this?
>
>
> Greetings,
> 0BIT
>
>
> unit P1_Unit1;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
> Dialogs, StdCtrls;
>
> type
> TForm1 = class(TForm)
> Memo1: TMemo;
> procedure FormShow(Sender: TObject);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> Form1: TForm1;
>
> implementation
>
> {$R *.dfm}
>
Try this:
procedure TForm1.FormShow(Sender: TObject);
begin
// Memo1.Realign; // why would you do that ?
Memo1.lines.LoadFromFile('yourTexttFile.txt');
end;
It will read the textfile into the memo each time the form is shown.
That is not an answer to your initial question: "want to add a .txt file
into the .exe." because in this case the textfile is just what it is: a txt
file. Make sure it is in the same directory as the exe file (otherwise check
help for param(0) and extractFileDir). I don't think you can link the txt
file into the exe. If you really want that, read everything about Resources.
Tom
Re: Including in .exe
Author: Leon Zandman
Date: Fri, 25 Jul 2003 00:05
Date: Fri, 25 Jul 2003 00:05
41 lines
3514 bytes
3514 bytes
> I have a program written for D6 and compiled it. > After compilation I want to add a .txt file into the .exe... > Then read with my program the added .txt file and put it into the memo... > How do I do this? I did this once, although it wasn't a text file I included, but some binary data. There are three ways I know that you can use to add some data to the EXE: 1) Just add the text file at the end of the EXE using a hex editor or some other util (or a program you've written yourself). This was the approach I used. The EXE still functioned perfectly. To extract the data I first determined the exact size of the EXE without the data attached. Then I compiled this value (offset) into the EXE (just assign it to a variable that was also included in the EXE that you used to measure the size; the size of the EXE won't change, only the value of this variable) and used a TStream descendant to get the data by reading from the EXE at that offset. 2) You can create a static data structure (e.g. string, array or record) filled with zero's (or NOP's) that is large enough to fit the text file. When you compile your program the structure will be included in your EXE (it will just be some empty space). Then you can replace this structure with the text file, again using a hex editor or something else. 3) You can add your text file as a resource. For some more information about resources see: http://delphi.about.com/library/weekly/aa021301a.htm You can add them from within Delphi, but in your case you'll have to add them afterwards. I don't know the tools, but I guess the Delphi compiler/linker itself can do the trick from the command-line. You could also use a program like ResourceHacker: http://www.users.on.net/johnson/resourcehacker/ I hope this info helps you :-) Greetz, Leon Zandman
Re: Including in .exe
Author: Peter Fox
Date: Fri, 25 Jul 2003 06:33
Date: Fri, 25 Jul 2003 06:33
13 lines
2392 bytes
2392 bytes
The correct method is to use resources - that's what they are for. If you really want to do this then here is another method. At design time write the text you want into memo or (rich edit). Make sure the text is large enough for all situations. After compiling hack using a hex editor. But all-in-all a lot of work for no gain. Whatever you are trying to achieve I think you'll find there is a better way of doing it. -- PETER FOX Not the same since the e-commerce business came to a . 2 Tees Close, Witham, Essex. peter@eminent.demon.co.uk_.com.net.org Free Delphi source for developers <http://www.eminent.demon.co.uk/delphi.htm>
Re: Including in .exe
Author: J French
Date: Fri, 25 Jul 2003 07:06
Date: Fri, 25 Jul 2003 07:06
50 lines
2588 bytes
2588 bytes
Append the data to the end of your EXE
- with a 'footer' record containing an ID and the length of the data
On Thu, 24 Jul 2003 19:54:51 GMT, "0BIT" <someone@123.com> wrote:
>I have a program written for D6 and compiled it.
>After compilation I want to add a .txt file into the .exe...
>Then read with my program the added .txt file and put it into the memo...
>How do I do this?
>
>
>Greetings,
>0BIT
>
>
>unit P1_Unit1;
>
>interface
>
>uses
> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
> Dialogs, StdCtrls;
>
>type
> TForm1 = class(TForm)
> Memo1: TMemo;
> procedure FormShow(Sender: TObject);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
>var
> Form1: TForm1;
>
>implementation
>
>{$R *.dfm}
>
>procedure TForm1.FormShow(Sender: TObject);
>begin
> Memo1.Realign;
>end;
>
>{SOMEWHERE I SHOULD READ THE .TXT FILE INTO THE MEMO ???}
>
>end.
>
>
Re: Including in .exe
Author: 0BIT
Date: Fri, 25 Jul 2003 12:29
Date: Fri, 25 Jul 2003 12:29
50 lines
3777 bytes
3777 bytes
Thanx for your information Greetings, 0BIT "Leon Zandman" <REMOVETHISleon@wirwar.com> wrote in message news:bfps83$v7h$1@news1.tilbu1.nb.home.nl... > > I have a program written for D6 and compiled it. > > After compilation I want to add a .txt file into the .exe... > > Then read with my program the added .txt file and put it into the > memo... > > How do I do this? > > I did this once, although it wasn't a text file I included, but some > binary data. There are three ways I know that you can use to add some > data to the EXE: > > 1) Just add the text file at the end of the EXE using a hex editor or > some other util (or a program you've written yourself). This was the > approach I used. The EXE still functioned perfectly. To extract the data > I first determined the exact size of the EXE without the data attached. > Then I compiled this value (offset) into the EXE (just assign it to a > variable that was also included in the EXE that you used to measure the > size; the size of the EXE won't change, only the value of this variable) > and used a TStream descendant to get the data by reading from the EXE at > that offset. > > 2) You can create a static data structure (e.g. string, array or record) > filled with zero's (or NOP's) that is large enough to fit the text file. > When you compile your program the structure will be included in your EXE > (it will just be some empty space). Then you can replace this structure > with the text file, again using a hex editor or something else. > > 3) You can add your text file as a resource. For some more information > about resources see: > http://delphi.about.com/library/weekly/aa021301a.htm > > You can add them from within Delphi, but in your case you'll have to add > them afterwards. I don't know the tools, but I guess the Delphi > compiler/linker itself can do the trick from the command-line. You could > also use a program like ResourceHacker: > http://www.users.on.net/johnson/resourcehacker/ > > I hope this info helps you :-) > > Greetz, > > Leon Zandman > >
Re: Including in .exe
Author: Maynard Philbrook
Date: Fri, 25 Jul 2003 15:29
Date: Fri, 25 Jul 2003 15:29
54 lines
2745 bytes
2745 bytes
you can use a Resource script file and add it to your project.
then at run time you can use a TResourceStream and then load a Memo with it.
ect..
0BIT wrote:
> I have a program written for D6 and compiled it.
> After compilation I want to add a .txt file into the .exe...
> Then read with my program the added .txt file and put it into the memo...
> How do I do this?
>
> Greetings,
> 0BIT
>
> unit P1_Unit1;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
> Dialogs, StdCtrls;
>
> type
> TForm1 = class(TForm)
> Memo1: TMemo;
> procedure FormShow(Sender: TObject);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> Form1: TForm1;
>
> implementation
>
> {$R *.dfm}
>
> procedure TForm1.FormShow(Sender: TObject);
> begin
> Memo1.Realign;
> end;
>
> {SOMEWHERE I SHOULD READ THE .TXT FILE INTO THE MEMO ???}
>
> end.
--
To See what real programmers do in their spare time visit
http://jamie12.home.mindspring.com
home of PC bit software ..
Please send comments about my work .
Re: Including in .exe
Author: epema
Date: Sun, 27 Jul 2003 06:25
Date: Sun, 27 Jul 2003 06:25
53 lines
2717 bytes
2717 bytes
Maybe it's kind of a workaround, but if you include a constants unit in your
project, including the textlines in separate constants it will be part of
your executable...
Kees
"0BIT" <someone@123.com> schreef in bericht
news:fQWTa.616794$V9.49538640@amsnews02.chello.com...
> I have a program written for D6 and compiled it.
> After compilation I want to add a .txt file into the .exe...
> Then read with my program the added .txt file and put it into the memo...
> How do I do this?
>
>
> Greetings,
> 0BIT
>
>
> unit P1_Unit1;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
> Dialogs, StdCtrls;
>
> type
> TForm1 = class(TForm)
> Memo1: TMemo;
> procedure FormShow(Sender: TObject);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> Form1: TForm1;
>
> implementation
>
> {$R *.dfm}
>
> procedure TForm1.FormShow(Sender: TObject);
> begin
> Memo1.Realign;
> end;
>
> {SOMEWHERE I SHOULD READ THE .TXT FILE INTO THE MEMO ???}
>
> end.
>
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads