View previous topic :: View next topic |
Author |
Message |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Sun Apr 20, 2008 2:57 am Post subject: Delphi file copying problem |
|
|
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 |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Sun Apr 20, 2008 3:05 am Post subject: |
|
|
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 |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Sun Apr 20, 2008 3:17 am Post subject: |
|
|
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 |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Sun Apr 20, 2008 4:10 am Post subject: |
|
|
i did what you said holyblah, but it still doesn't work
i also tried movefile, still didn't work
_________________
|
|
Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Sun Apr 20, 2008 4:51 am Post subject: |
|
|
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 |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Sun Apr 20, 2008 5:21 am Post subject: |
|
|
i tried something like that, no dice
_________________
|
|
Back to top |
|
 |
--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?
|
|
Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Sun Apr 20, 2008 7:18 am Post subject: |
|
|
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 |
|
 |
|