SelfDelete Funktion für Deinstallationen oder ähnliches
Hi,
Ich habe mir eine Deinstallation geproggt und da bin ich auf das Problem gestoßen, dass die Deinstallation exe auch gelöscht werden muss. Deshalb habe ich eine kleine Funktion geschrieben, die mithilfe einer bat Datei die Exe nach dem Beenden löscht. Hier der Source:
Delphi-Quellcode:
Ich hoffe es hilft euch!
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ShellApi; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure SelfDelete(); var TempDir: string; BatFile: TStringList; begin TempDir := GetEnvironmentVariable('Temp'); BatFile := TStringList.Create; BatFile.Add('ping -n 0127.0.0.1 > nul'); BatFile.Add(':loop'); BatFile.Add('del "' + Application.ExeName + '" > nul'); BatFile.Add('if exist "' + Application.ExeName + '" goto loop'); BatFile.Add('del "' + TempDir + 'selfdelete.bat' + '"'); BatFile.SaveToFile(TempDir + 'selfdelete.bat'); BatFile.Free; ShellExecute(Form1.Handle, nil, PChar(TempDir + 'selfdelete.bat'), nil, nil, SW_HIDE); end; procedure TForm1.FormCreate(Sender: TObject); begin SelfDelete(); end; end. |
Re: SelfDelete Funktion für Deinstallationen oder ähnliches
Warum pingst du den localhost an?
|
Re: SelfDelete Funktion für Deinstallationen oder ähnliches
Und wieso lässt du das nicht Windows mit MoveFileEx für dich erledigen?
Zitat:
|
Re: SelfDelete Funktion für Deinstallationen oder ähnliches
Zitat:
|
Re: SelfDelete Funktion für Deinstallationen oder ähnliches
Zitat:
|
Re: SelfDelete Funktion für Deinstallationen oder ähnliches
Zitat:
|
Re: SelfDelete Funktion für Deinstallationen oder ähnliches
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:46 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz