AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Applikation bei Laufzeit löschen

Ein Thema von Eggimaa · begonnen am 17. Jun 2004 · letzter Beitrag vom 17. Jun 2004
Antwort Antwort
Lillebrohr
(Gast)

n/a Beiträge
 
#1

Re: Applikation bei Laufzeit löschen

  Alt 17. Jun 2004, 14:48
Hi leute,

na und ob das geht.

Code:
Improved version, works under 95,98, NT4.0 and 2000.

program SelfDelete;

uses
  windows,sysutils;

procedure DeleteExeAndDir;
var hModule:THandle;
 szModuleName,szDirName:array[0..MAX_PATH] of char;
   hKrnl32 : THandle;
   pExitProcess, pDeleteFile, pFreeLibrary,pUnmapViewOfFile,pRemoveDir : pointer;
   ExitCode:UINT; var r:integer;
begin
 hModule:= GetModuleHandle(nil);

 GetModuleFileName(hModule, szModuleName, sizeof(szModuleName));
 StrPCopy(szDirName,ExtractFileDir(szModuleName));

     hKrnl32 := GetModuleHandle ( 'kernel32' );
     pExitProcess := GetProcAddress ( hKrnl32, 'ExitProcess' );
     pDeleteFile := GetProcAddress ( hKrnl32, 'DeleteFileA' );
     pFreeLibrary := GetProcAddress ( hKrnl32, 'FreeLibrary' );
     pUnmapViewOfFile := GetProcAddress ( hKrnl32, 'UnmapViewOfFile' );
     pRemoveDir := GetProcAddress ( hKrnl32, 'RemoveDirectoryA' );

 ExitCode := system.ExitCode;

 SetCurrentDirectory(pchar(ExtractFileDir(szDirName)));
 if($80000000 and GetVersion())<>0 then
  // Win95, 98, Me
  asm
   lea    eax, szModuleName
   lea    ecx, szDirName
   push   ExitCode
   push   0
   push   ecx
   push   pExitProcess
   push   eax
   push   pRemoveDir
   push   hModule
   push   pDeleteFile
   push   pFreeLibrary
   ret
  end
 else
  begin
    for r:=1 to 100 do
    begin
      CloseHandle(r shl 2);
    end;
//  CloseHandle(THANDLE(4));
  asm
   lea    eax, szModuleName
   lea    ecx, szDirName
   push   ExitCode
   push   0
   push   ecx
   push   pExitProcess
   push   eax
   push   pRemoveDir
   push   hModule
   push   pDeleteFile
   push   pUnmapViewOfFile
   ret
   end
  end

end;

begin
     DeleteExeAndDir
end.
Viel Spaß dabei.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:17 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz