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]How do I delete a file?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
ZOMGWTFSUREHAXXINGBBQ
Advanced Cheater
Reputation: 0

Joined: 05 Jun 2007
Posts: 61

PostPosted: Wed Jun 06, 2007 2:34 pm    Post subject: [DELPHI]How do I delete a file? Reply with quote

How do I delete a file? Like, say I want it to erase a MapleStory.exe, I enter like 5 different filepaths, since there are multiple areas MapleStory gets put into, then it deletes the one it finds? how would I do that?
_________________
Yes, I'm Hixk, stop asking!
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Wed Jun 06, 2007 2:39 pm    Post subject: Reply with quote

http://msdn2.microsoft.com/En-US/library/aa363915.aspx
Back to top
View user's profile Send private message
ZOMGWTFSUREHAXXINGBBQ
Advanced Cheater
Reputation: 0

Joined: 05 Jun 2007
Posts: 61

PostPosted: Wed Jun 06, 2007 2:41 pm    Post subject: Reply with quote

k, but, in
Code:
BOOL DeleteFile(
  LPCTSTR lpFileName
);

that, the lpfilename is where I put the filepath or what?

_________________
Yes, I'm Hixk, stop asking!
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Wed Jun 06, 2007 2:50 pm    Post subject: Reply with quote

Yes, LPCTSTR is a C string (array of characters, or PChar in delphi)
Back to top
View user's profile Send private message
ZOMGWTFSUREHAXXINGBBQ
Advanced Cheater
Reputation: 0

Joined: 05 Jun 2007
Posts: 61

PostPosted: Wed Jun 06, 2007 3:20 pm    Post subject: Reply with quote

I was planning on this: Making a button on a delphi program to delete the gameguard folder/change hosts file. Kinda like simple click, but for my own purposes. I can't seem to work the deletefile funct. into a button though, and google sucks for delphi codes. If you know how to work it into a button, please help me appal, I just started delphi yesterday :S...
_________________
Yes, I'm Hixk, stop asking!
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Wed Jun 06, 2007 3:29 pm    Post subject: Reply with quote

To delete a folder you need to first delete all the files in it, then use RemoveDirectory.
Back to top
View user's profile Send private message
ZOMGWTFSUREHAXXINGBBQ
Advanced Cheater
Reputation: 0

Joined: 05 Jun 2007
Posts: 61

PostPosted: Wed Jun 06, 2007 3:38 pm    Post subject: Reply with quote

Arrgh...Okay, how would I work deleting the FILES without writing to them first out? All the tuts I find are saying to write to them first, so I don't know how to enter a file path, then have it delete the file at the end of the path...
_________________
Yes, I'm Hixk, stop asking!
Back to top
View user's profile Send private message
UnLmtD
Grandmaster Cheater
Reputation: 0

Joined: 13 Mar 2007
Posts: 894
Location: Canada

PostPosted: Wed Jun 06, 2007 3:40 pm    Post subject: Reply with quote

EDIT: Oups seems that you can use SHFileOperation, but I learned doing this way (It's in C++) "rgValue" holds GG path
Code:
        char searchname[MAX_PATH];
        WIN32_FIND_DATA wfdData;
        HANDLE hFind;
        BOOL keeplooking;
        char filename[MAX_PATH];
           
             sprintf(searchname, "%s\\*.*", rgValue);
             hFind = FindFirstFile(searchname, &wfdData);
             keeplooking = 1;
             if(hFind == INVALID_HANDLE_VALUE){
             MessageBox(Hwnd, Error, "GameGuard Folder Not Found", MB_OK );
                    }
         
          if(hFind != INVALID_HANDLE_VALUE)
          {
            
             while(keeplooking)
        {
            sprintf(filename, "%s\\%s", rgValue, wfdData.cFileName);
            DeleteFile(filename);
            keeplooking = FindNextFile(hFind, &wfdData);
        }
            FindClose( hFind );
             RemoveDirectory(rgValue);


What this does is, it searches the folder, every file it finds it will delete it, and then when no files are found it delete the folder

_________________


Last edited by UnLmtD on Wed Jun 06, 2007 7:05 pm; edited 1 time in total
Back to top
View user's profile Send private message
ZOMGWTFSUREHAXXINGBBQ
Advanced Cheater
Reputation: 0

Joined: 05 Jun 2007
Posts: 61

PostPosted: Wed Jun 06, 2007 3:46 pm    Post subject: Reply with quote

That's not delphi, so I can't use it man, thanks for posting though!
_________________
Yes, I'm Hixk, stop asking!
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Wed Jun 06, 2007 4:16 pm    Post subject: Reply with quote

zomgiownyou wrote:
But there isn't an API that will delete all files in a Folder, so you will have to do this way


Actually, that's not true, SHFileOperation can recursively delete files in a folder.
Back to top
View user's profile Send private message
UnLmtD
Grandmaster Cheater
Reputation: 0

Joined: 13 Mar 2007
Posts: 894
Location: Canada

PostPosted: Wed Jun 06, 2007 4:26 pm    Post subject: Reply with quote

O yeah? Well long time ago, when I didn't know how to do that, devlopper( Matt on IRC I believe) told me this way of doing it.
_________________
Back to top
View user's profile Send private message
ZOMGWTFSUREHAXXINGBBQ
Advanced Cheater
Reputation: 0

Joined: 05 Jun 2007
Posts: 61

PostPosted: Wed Jun 06, 2007 5:10 pm    Post subject: Reply with quote

So, how would I do it in Delphi?
_________________
Yes, I'm Hixk, stop asking!
Back to top
View user's profile Send private message
raygodl
Master Cheater
Reputation: 0

Joined: 30 Jun 2006
Posts: 260

PostPosted: Wed Jun 06, 2007 9:11 pm    Post subject: autoit question Reply with quote

ex:
C:\Documents and Settings\Administrator\Desktop

how do i get to desktop from any computer but the admin will change to whatever user it is on???

_________________
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Jun 07, 2007 7:41 am    Post subject: Reply with quote

This is what I got. Make a button on delphi. ON button click tell it to begin deleting with this code.

Code:

BOOL DeleteFile(
  LPCTSTR lpFileName //In here I put the file directory, that includes like .dll and .exe right?
);


For example


Code:

BOOL DeleteFile(
  LPCTSTR C:\Program Files\Wizet\MapleStory\MapleStory.exe
);

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
UnLmtD
Grandmaster Cheater
Reputation: 0

Joined: 13 Mar 2007
Posts: 894
Location: Canada

PostPosted: Thu Jun 07, 2007 8:04 am    Post subject: Reply with quote

^^^ its
Code:
   DeleteFile(
   "C:\\Program Files\\Wizet\\MapleStory\\MapleStory.exe"
    );


Don't add a hardcoded path.

_________________
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
Goto page 1, 2  Next
Page 1 of 2

 
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