Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Delphi file copying problem

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Sun Apr 20, 2008 2:57 am    Post subject: Delphi file copying problem Reply with quote

so i'm trying to make a console app to copy my font to the font file, so you dont need to do it yourself, this is what i've got (delphi btw)

Code:
program SnootaeBotFontChecker;

{$APPTYPE CONSOLE}

uses
  SysUtils, Windows;

  var
  dir: string;
  fontdir: string;
  fontfile: string;

begin
   Write('---   Snootae Bot  Font Installer   ---' + #$0A+#$0D);
   Sleep(500);
   Write(#$0A+#$0D'Checking if font is on your computer...' + #$0A+#$0D);
   Sleep(1000);


   if FileExists('C:\WINDOWS\slkscr.ttf') then
   begin
   Write('Font is already on your computer' + #$0A+#$0D);
   Write(#$0A+#$0D + 'Exiting...');
   Sleep(2000);
   Exit;
   end;

   if not FileExists('C:\WINDOWS\slkscr.ttf') then
   begin
     Write('Font is not already on your computer' + #$0A+#$0D);
     Write('Copying Font...' + #$0A+#$0D);
     dir := GetCurrentDir;
     fontdir := dir + 'slkscr.ttf';
     fontfile := 'C:\WINDOWS\Fonts';
     CopyFile(PChar(fontdir), PChar(fontfile), true);
     Sleep(1000);
     Write('Font Copied' + #$0A+#$0D);
     Write(#$0A+#$0D + 'Exiting...');
     Sleep(2000);
     Exit;
   end;
end.


the slkscr.ttf file definitely exists, but does not get copied, i even tried pointing directly to a .exe, and trying to copy it to a random folder, but it does not copy, and ideas why?

_________________
Back to top
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Sun Apr 20, 2008 3:05 am    Post subject: Reply with quote

MSDN:
Code:
BOOL WINAPI CopyFile(
  __in  LPCTSTR lpExistingFileName,
  __in  LPCTSTR lpNewFileName,
  __in  BOOL bFailIfExists
);
So:
Code:
if not FileExists('C:\WINDOWS\Fonts\slkscr.ttf') then
   begin
     Write('Font is not already on your computer' + #$0A+#$0D);
     Write('Copying Font...' + #$0A+#$0D);
     dir := GetCurrentDir;
     fontdir := dir + 'slkscr.ttf';
     fontfile := 'C:\WINDOWS\Fonts\slkscr.ttf';//<<<< should be the full name of file(not the folder).
     CopyFile(PChar(fontdir), PChar(fontfile), true);
     Sleep(1000);
     Write('Font Copied' + #$0A+#$0D);
     Write(#$0A+#$0D + 'Exiting...');
     Sleep(2000);
     Exit;
   end;
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sun Apr 20, 2008 3:17 am    Post subject: Reply with quote

declare the 3 variable as a string in 1 line.

s,s1,s2:string;

make dir = GetCurrentDir a global variable

use MoveFile(); ? (does it matter if it's a copy ?)
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Sun Apr 20, 2008 4:10 am    Post subject: Reply with quote

i did what you said holyblah, but it still doesn't work

i also tried movefile, still didn't work

_________________
Back to top
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Sun Apr 20, 2008 4:51 am    Post subject: Reply with quote

Just a slash:
Code:
if not FileExists('C:\WINDOWS\Fonts\slkscr.ttf') then
   begin
     Write('Font is not already on your computer' + #$0A+#$0D);
     Write('Copying Font...' + #$0A+#$0D);
     dir := GetCurrentDir;
     fontdir := dir+'\Vera.ttf';
                 //^^
     fontfile := 'C:\WINDOWS\Fonts\slkscr.ttf';
     CopyFile(PChar(fontdir), PChar(fontfile), true);
     Sleep(1000);
     Write('Font Copied' + #$0A+#$0D);
     Write(#$0A+#$0D + 'Exiting...');
     Sleep(2000);
     Exit;
   end;
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Sun Apr 20, 2008 5:21 am    Post subject: Reply with quote

i tried something like that, no dice
_________________
Back to top
View user's profile Send private message
--Pillboi--
Grandmaster Cheater Supreme
Reputation: 0

Joined: 06 Mar 2007
Posts: 1383
Location: I don't understand the question. Is this a 1 to 10 thing?

PostPosted: Sun Apr 20, 2008 6:28 am    Post subject: Reply with quote

Links found on google that might help:
http://www.delphicorner.f9.co.uk/articles/misc4.htm
http://www.scip.be/index.php?Page=ArticlesDelphi08&Lang=EN
http://www.delphifaq.net/how-to-copymove-fileshow-to-copy-move-files/
Hope these help.

_________________

Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair.
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Sun Apr 20, 2008 7:18 am    Post subject: Reply with quote

hmm, i got it to work, i changed it to:
Code:

dir := GetCurrentDir;
fontdir := dir + '\\slkscr.ttf';
fontfile := 'C:\\WINDOWS\\Fonts\\slkscr.ttf';
CopyFile(PChar(fontdir), PChar(fontfile), true);


the double slash seems to make a difference

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites