//--------------------------------------------------------------------------- #include #pragma hdrstop #include #include #include "Empaquetador.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Edit1DblClick(TObject *Sender) { OpenDialog1->DefaultExt = "MTX"; OpenDialog1->FileName = "*.mtx"; if (OpenDialog1->Execute()) { Edit1->Text = OpenDialog1->FileName; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Edit4DblClick(TObject *Sender) { OpenDialog1->DefaultExt = "ZIP"; OpenDialog1->FileName = "*.zip"; if (OpenDialog1->Execute()) { Edit4->Text = OpenDialog1->FileName; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Memo1DblClick(TObject *Sender) { OpenDialog1->DefaultExt = "TXT"; OpenDialog1->FileName = "*.txt"; if (OpenDialog1->Execute()) { Memo1->Lines->LoadFromFile( OpenDialog1->FileName ); } } //--------------------------------------------------------------------------- void __fastcall TForm1::Memo2DblClick(TObject *Sender) { OpenDialog1->DefaultExt = "TXT"; OpenDialog1->FileName = "*.txt"; if (OpenDialog1->Execute()) { Memo2->Lines->LoadFromFile( OpenDialog1->FileName ); } } //--------------------------------------------------------------------------- void __fastcall TForm1::Anexa( FILE *out, AnsiString FICH ) { FILE *mtx; int charc; if ( (mtx = fopen( (FICH.c_str()), "rb" ) ) != NULL ) { while( (charc = fgetc(mtx) ) != EOF ) fputc( charc, out ); fclose( mtx ); } } //--------------------------------------------------------------------------- int FILE_LENGHT( char *X ) { int handle, Y; handle = open( X, 0 ); Y = filelength(handle); close(handle); return Y; } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { SaveDialog1->DefaultExt = "EXE"; SaveDialog1->FileName = "*.exe"; if (SaveDialog1->Execute()) { long longitud; FILE *out; #define infor "TMP1-informacion.txt" #define licencia "TMP2-licencia.txt" if ( (out = fopen( (SaveDialog1->FileName).c_str(), "wb" ) ) != NULL ) { // Copiamos MATRIX Anexa( out, Edit1->Text ); // Informacion de interes... char longt; longt = (char)Edit2->Text.Length(); fputc( longt, out ); longt = (char)Edit3->Text.Length() + 4; fputc( longt, out ); fputc( 0x00, out ); fputc( 0x00, out ); int tinfo, tlic; Memo1->Lines->SaveToFile( infor ); tinfo = FILE_LENGHT( infor ); Memo2->Lines->SaveToFile( licencia ); tlic = FILE_LENGHT( licencia ); fwrite( &tinfo, sizeof( int ), 1, out ); fwrite( &tlic, sizeof( int ), 1, out ); fputc( 0x00, out ); fputc( 0x00, out ); fputc( 0x00, out ); fputc( 0x00, out ); fputc( 0x80, out ); fputc( 0x92, out ); fputc( 0x00, out ); fputc( 0x00, out ); fputs( (Edit2->Text).c_str(), out ); fputs( (Edit3->Text).c_str(), out ); fputs( ".INF", out ); Anexa( out, infor ); Anexa( out, licencia ); Anexa( out, Edit4->Text ); fclose( out ); } } } //---------------------------------------------------------------------------