1. Home
  2. Computing & Technology
  3. Delphi Programming

Delphi application that copies itself

By , About.com Guide

Here's a sample code from a Delphi application that can copy itself anywhere on the system.

To call this function place the next call anywhere inside your code:

SelfCopy('c:\Windows\Temp\myappcopy.exe')

~~~~~~~~~~~~~~~~~~~~~~~~~
function SelfCopy(const sPath : string) : boolean
begin
  Result:=True;
  if NOT Windows.CopyFile(PChar(ParamStr(0)), PChar(sPath), true) then
  begin
    RaiseLastWin32Error;
    Result:=False;
  end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» How to convert Seconds to Time
« Correct date format for SQL

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2003 Delphi Tips
  7. Delphi application that copies itself

©2009 About.com, a part of The New York Times Company.

All rights reserved.