PDA

Ver la Versión Completa : Meter un txt dentro de un exe


D@byt
02-06-2005, 11:11:49
¿Puedo incluir un fichero txt dentro de un ejecutable? Si se puede me podría decir alguien la forma para hacerlo.
Gracias a todos.

Neftali [Germán.Estévez]
02-06-2005, 11:40:06
Utiliza recursos.
Extracto de un mensaje donde se explica el proceso...

//-------------------------------------------------------
You can store any kind of file as a RCDATA resource.

The following example shows this with an RTF file.

Load RTF file from resource:
Create a file textres.rc:
TESTDOC RCDATA "textdoc.rtf"
Compile this with brcc32 to textres.res.
Include it into your project with an {$R textres.res} line.
Use it similar to this method.


procedure TForm1.Button2Click(Sender: TObject);
var
rs: TResourceStream;
Begin
rs := TResourceStream.Create( hinstance, 'TESTDOC', RT_RCDATA );
try
richedit1.plaintext :=false;
richedit1.lines.loadfromstream(rs);
finally
rs.free;
end;
end;

//-------------------------------------------------------