Merhaba.
Gönderdiğim sitenin veritabanı sorunsalıdır.
Tozlu raflardan çıkardım

kodlar aşağıdaki şekilde.
Dilerseniz diske yazar kullanırsınız dilerseniz MemoryStream'e atar DLL ise LoadLibrary( ) FreeLibrary( ) ile dilerseniz nette bulabileceğiniz şekilde EXE from Stream gibi kullanabilirsiniz.
Var
xDurdur : Boolean = False;
procedure FileToUnit( aSourceFile: String; aTargetUnit, aFunc:TStrings; aStatusPanel:TStatusPanel; aGauge: TGauge );
var
fsDosya : TFileStream;
strHedef : String;
bBuffer : array of byte;
iSayac,
iByteSay : Integer;
strUnit,
strSatir : String;
tBas, tTahmin: TDateTime;
boolIlkSatir : Boolean;
begin
tBas := Now();
// Dosya yoksa dışarı...
if NOT FileExists(aSourceFile) then EXIT;
TThread.CreateAnonymousThread( procedure
begin
strUnit := 'Delphi_' + ExtractFileName(ChangeFileExt(aSourceFile, ''));
strHedef := ExtractFilePath( aSourceFile ) + strUnit + '.PAS';
// Func
With aFunc do begin
Clear;
Add( '// Dönüşüm Fonksiyonu //' );
Add( '// ------------------ //' );
Add( '' );
Add('USES ' + strUnit );
Add( '' );
Add( 'Function Donusum( strDosyaAdi: String ): Boolean; ');
Add( 'Var ');
Add( ' fsDosya : TFileStream; ');
Add( 'begin ');
Add( ' Result := False; ');
Add( ' Try ');
Add( ' fsDosya := TFileStream.Create( strDosyaAdi, fmCreate ); ');
Add( ' fsDosya.Write( Dizi_'+strUnit+', High( Dizi_'+strUnit+')+1 ); ');
Add( ' fsDosya.Free; ');
Add( ' Finally');
Add( ' Result := True; ');
Add( ' End;');
Add( 'end; ');
Add( '' );
Add( '// Herhangi bir dosya ise aşağıdaki şekil yeterli // ');
Add( 'begin; ');
Add( ' Donusum( ExtractFilePath(Application.Exename) + strOrjDosya ) ');
Add( 'end; ');
Add( '' );
Add( '' );
end; // with
// UNIT
With aTargetUnit do begin
Clear;
Add( Format('Unit %s;', [ strUnit ]) );
Add( '' );
Add( 'Interface' );
Add( '' );
Add( 'Const' );
Add( ' strOrjDosya = '+ QuotedStr( ExtractFileName(aSourceFile) )+';' );
Add( '' );
end; // with
fsDosya := TFileStream.Create( aSourceFile, fmOpenread );
aTargetUnit.Add( Format(' Dizi_%s : Array [0..%d] of Byte = ', [ strUnit, fsDosya.Size - 1 ]) );
aTargetUnit.Add(' (');
SetLength( bBuffer, fsDosya.Size );
fsDosya.Read( bBuffer[0], fsDosya.Size );
iSayac := 0;
iByteSay := 0;
strSatir := '';
if aGauge <> nil then
begin
aGauge.MinValue := 0;
aGauge.MaxValue := fsDosya.Size;
aGauge.Visible := True;
end;
boolIlkSatir := True;
aTargetUnit.BeginUpdate;
while (iSayac < fsDosya.Size) AND (NOT xDurdur) do
begin
if iByteSay = 0 then
begin
if strSatir <> '' then aTargetUnit.Add( strSatir );
iByteSay := 30;
strSatir := '';
// 10 100 byte
tTahmin := tBas;
if iSayac > 0 then
tTahmin := IncMilliSecond( tBas, (fsDosya.Size * MilliSecondsBetween( Now(), tBas ) div iSayac) );
if aStatusPanel <> nil
then aStatusPanel.Text := Format('%d / %d byte (-%d sn.)', [iSayac, fsDosya.Size, SecondsBetween(tTahmin, Now()) ]);
end;
if strSatir = '' then
begin
if boolIlkSatir then
begin
strSatir := Format(' $%.2x', [ bBuffer[iSayac] ]);
boolIlkSatir := False;
end else begin
strSatir := Format(' ,$%.2x', [ bBuffer[iSayac] ]);
end;
end
else strSatir := strSatir + Format(',$%.2x', [ bBuffer[iSayac] ]);
inc(iSayac);
Dec(iByteSay);
if aGauge <> nil then
TThread.Synchronize(nil, procedure
begin
aGauge.Progress := iSayac;
end );
// Application.ProcessMessages;
end; // while
aTargetUnit.EndUpdate;
if strSatir <> '' then aTargetUnit.Add( strSatir );
if aGauge <> nil then aGauge.Visible := False;
if xDurdur then
begin
aTargetUnit.Add('');
aTargetUnit.Add('// -------------------------------------------- //');
aTargetUnit.Add('// !!! Kullanıcı Tarafından Durduruldu !!! //');
aTargetUnit.Add('// -------------------------------------------- //');
end else
begin
aTargetUnit.Add(' );');
aTargetUnit.Add('implementation');
aTargetUnit.Add('end.');
end;
end ).Start;
fsDosya.Free;
end;
Kullanımı :
Edit1 : Kaynak Dosya
Memo1 : Üretilen Unit
Memo2 : dönüşüm Function
StatusBar Panel : Durum ve kalan süre
Gauge1 : % olarak durum
- işlem sırasında global değişken xDurdur değeri TRUE olursa işlem iptal edilip döngüden çıkılır.
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
if TBitBtn(Sender).Caption = 'Dönüştür' then
begin
BitBtn3.Enabled := False;
xDurdur := False;
TBitBtn(Sender).Caption := 'Durdur';
Memo1.Visible := False;
FileToUnit( Edit1.Text, Memo1.Lines, Memo2.Lines, StatusBar1.Panels[0], Gauge1 );
Memo1.Visible := True;
BitBtn3.Enabled := True;
end else begin
BitBtn3.Enabled := True;
xDurdur := True;
TBitBtn(Sender).Caption := 'Dönüştür';
Memo1.Visible := True;
end;
end;