Write a function in Delphi 7 - and a contact for further work: questions paid per question

Cancelled Posted 7 years ago Paid on delivery
Cancelled Paid on delivery

Hi

I am building a chat application in Delphi 7, and I want to make a copy of my application in the 'Windows' folder, to save incase it will be restored at a later time.

I need a function, OnClick of a button that does:

Copies my application to the Windows Folder, if it's not already there.

(it will have to get the path and filename of the current application)

(it will need to get the windows folder)

(and it will need to copy itself there with a new name: '[login to view URL]')

Appreciate the help thanks!

Chris.

So far I have this testing code: Although it only works some times?

procedure TForm1.Button1Click(Sender: TObject);
var
GetWinDir : array [0..255]of Char;
WinDirNoSlash : string;
curdir: string;
windir: string;
lowcaseWD, lowcaseCD, localfile: string;
begin
CurrentDir := ExtractFilePath(ParamStr(0)); // e.g c:\MyPath\
GetWindowsDirectory(GetWinDir, 255);
WinDirNoSlash := GetWinDir; // e.g c:\windows
WindowsDir := WinDirNoSlash + ''; // e.g c:\windows\
{4} DriveOfWin := Copy(WindowsDir, 1, 3); // e.g c:\

curdir := ParamStr(0);
windir := WindowsDir;

localfile := LowerCase(curdir);
lowcaseWD := LowerCase(WindowsDir);
lowcaseCD := LowerCase(CurrentDir);

ShowMessage('CD:"' + lowcaseCD + '" WD: "' + lowcaseWD);



if (lowcaseCD <> lowcaseWD) then
begin
CopyFile(PChar(localfile), PChar(lowcaseWD + 'myApp.exe'), TRUE);
showmessage('"FILE COPIED!" '+ localfile + '" ' + lowcaseWD + 'myApp.exe');
end else begin
ShowmEssage('In win dir!');
end;
end;

I am infact going to use this method to try and prevent 'cracking' of my software.

I have tried this simple line:

CopyFile(PChar(ParamStr(0)), PChar('c:\windows\myApp.exe'), False);

And it does not work??

Thanks and best regards,

Chris

hmm, i think it could be a permissions issue. Wondering where else I can use to copy my .exe.

OK, perhaps forget the Windows folder if I dont have permissions. Is there another folder - special folders? on Windows 10 I can use?

Thanks!

Delphi Software Architecture

Project ID: #10961625

About the project

1 proposal Remote project Active 7 years ago

1 freelancer is bidding on average $30 for this job

tamysguimaraes

A proposal has not yet been provided

$30 USD in 2 days
(0 Reviews)
0.0