1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| //------------------------------------------------------------------------------
class procedure TExternalTools.RunBidule(const AFileName1, AFileName2: string);
var
VPath, VPathBidule: string;
RS: TResourceStream;
ZLib: TCustomZStream;
FS: TFileStream;
{$IFDEF DEBUG}
VPathBiduleZK: string;
FSZK: TFileStream;
{$ENDIF DEBUG}
begin
VPath := ExtractFilePath(Application.ExeName);
VPathBidule := VPath + 'Bidule.exe';
{$REGION 'Compression pour mise en ressources'}
{$IFDEF DEBUG}
if LongBool(GetAsyncKeyState(VK_SHIFT) and $8000) then
begin
VPathBiduleZK := 'Bidule.rcdata';
if PromptForFileName(VPathBidule, 'Executable Bidule|Bidule.exe', '.exe', 'Bidule à compresser', VPath) and PromptForFileName(VPathBiduleZK, 'Ressource Bidule|Bidule.rcdata', '.rcdata', 'Bidule à compresser', VPath, True) then
begin
FS := TFileStream.Create(VPathBidule, fmOpenRead);
try
try
FSZK := TFileStream.Create(VPathBiduleZK, fmCreate);
try
ZLib := TZCompressionStream.Create(clMax, FSZK);
try
ZLib.CopyFrom(FS, 0);
finally
ZLib.Free();
end;
finally
FSZK.Free();
end;
except
System.IOUtils.TFile.Delete(VPathBidule);
end;
finally
FS.Free();
end;
Exit;
end;
end;
{$ENDIF DEBUG}
{$ENDREGION}
{$REGION 'Extraction Ressource'}
if not FileExists(VPathBidule) then
begin
RS := TResourceStream.Create(HInstance, 'ZIP_Bidule', System.Types.RT_RCDATA);
try
ZLib := TZDecompressionStream.Create(RS);
try
try
FS := TFileStream.Create(VPathBidule, fmCreate);
try
FS.CopyFrom(ZLib, 0);
finally
FS.Free();
end;
except
System.IOUtils.TFile.Delete(VPathBidule);
end;
finally
ZLib.Free();
end;
finally
RS.Free();
end;
end;
{$ENDREGION}
ShellExecute(Screen.ActiveForm.Handle, 'open', PChar(VPathBidule), PChar(Format('"%s" "%s"', [AFileName1, AFileName2])), PChar(VPath), SW_SHOW);
end; |
Partager