| View previous topic :: View next topic |
| Author |
Message |
ZOMGWTFSUREHAXXINGBBQ Advanced Cheater
Reputation: 0
Joined: 05 Jun 2007 Posts: 61
|
Posted: Wed Jun 06, 2007 2:34 pm Post subject: [DELPHI]How do I delete a file? |
|
|
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 |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
|
| Back to top |
|
 |
ZOMGWTFSUREHAXXINGBBQ Advanced Cheater
Reputation: 0
Joined: 05 Jun 2007 Posts: 61
|
Posted: Wed Jun 06, 2007 2:41 pm Post subject: |
|
|
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 |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Wed Jun 06, 2007 2:50 pm Post subject: |
|
|
| Yes, LPCTSTR is a C string (array of characters, or PChar in delphi) |
|
| Back to top |
|
 |
ZOMGWTFSUREHAXXINGBBQ Advanced Cheater
Reputation: 0
Joined: 05 Jun 2007 Posts: 61
|
Posted: Wed Jun 06, 2007 3:20 pm Post subject: |
|
|
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 |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Wed Jun 06, 2007 3:29 pm Post subject: |
|
|
| To delete a folder you need to first delete all the files in it, then use RemoveDirectory. |
|
| Back to top |
|
 |
ZOMGWTFSUREHAXXINGBBQ Advanced Cheater
Reputation: 0
Joined: 05 Jun 2007 Posts: 61
|
Posted: Wed Jun 06, 2007 3:38 pm Post subject: |
|
|
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 |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Wed Jun 06, 2007 3:40 pm Post subject: |
|
|
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 |
|
 |
ZOMGWTFSUREHAXXINGBBQ Advanced Cheater
Reputation: 0
Joined: 05 Jun 2007 Posts: 61
|
Posted: Wed Jun 06, 2007 3:46 pm Post subject: |
|
|
That's not delphi, so I can't use it man, thanks for posting though! _________________
Yes, I'm Hixk, stop asking! |
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Wed Jun 06, 2007 4:16 pm Post subject: |
|
|
| 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 |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Wed Jun 06, 2007 4:26 pm Post subject: |
|
|
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 |
|
 |
ZOMGWTFSUREHAXXINGBBQ Advanced Cheater
Reputation: 0
Joined: 05 Jun 2007 Posts: 61
|
Posted: Wed Jun 06, 2007 5:10 pm Post subject: |
|
|
So, how would I do it in Delphi? _________________
Yes, I'm Hixk, stop asking! |
|
| Back to top |
|
 |
raygodl Master Cheater
Reputation: 0
Joined: 30 Jun 2006 Posts: 260
|
Posted: Wed Jun 06, 2007 9:11 pm Post subject: autoit question |
|
|
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 |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Thu Jun 07, 2007 7:41 am Post subject: |
|
|
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 |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Thu Jun 07, 2007 8:04 am Post subject: |
|
|
^^^ its | Code: | DeleteFile(
"C:\\Program Files\\Wizet\\MapleStory\\MapleStory.exe"
); |
Don't add a hardcoded path. _________________
|
|
| Back to top |
|
 |
|