How can I make my Delphi 7 program save itself into a new location. For example the program is saved on my flash stick then when I run it I want it to save itself in c:\user \ (user name)
The above is the original question.
This is the code I tried using. The program runs perfectly but when I check the folder it was supposed to save it in it does not appear there.
procedure TForm5.FormActivate(Sender: TObject);
var source, dest : string;
begin
Source := 'project1.exe';
Dest := 'C:\Users\Craig\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup';
CopyFile(PChar(Source), PChar(Dest), False);
end;
Thanks for your help.
Read the executable file name from Application.ExeName. And then call CopyFile to perform the copy.
Regarding your update:
CopyFile, you need to check the return value.You want something like this: