| View previous topic :: View next topic |
| Author |
Message |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Sep 14, 2007 6:59 pm Post subject: deleting files in C++ |
|
|
lol i nvr learned, how do i delete files in C++?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
Last edited by oib111 on Fri Sep 14, 2007 9:35 pm; edited 2 times in total |
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Fri Sep 14, 2007 7:11 pm Post subject: Re: closing a program in C++ |
|
|
| oib111 wrote: | | If I wanted to close a program for examploe lets say an untitled notepad, can i do it this way? | WM_QUIT isn't send to the window message queue.. WM_CLOSE is, but it only closes the window.
| oib111 wrote: | | Oh and is there anyway to send the WM_QUIT message to notepad, like all notepad files instead of only the untitled one. |
| Code: | HWND notepadHWND;
do {
notepadHWND = ::FindWindow( TEXT("Notepad"), NULL );
if(notepadHWND) {
::PostMessage(notepadHWND, WM_QUIT, 0, NULL);
::Sleep(10) // Give it some time to quit
}
} while(notepadHWND!=NULL); |
PS. It's almost 5 am, I hope I got it right :p
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Fri Sep 14, 2007 7:14 pm Post subject: |
|
|
send the message WM_CLOSE and WM_DESTROY or maybe just WM_DESTROY because when you send close it sends destroy
_________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Sep 14, 2007 7:16 pm Post subject: |
|
|
Ok, well, now I really need to know how to close a process.
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Fri Sep 14, 2007 7:18 pm Post subject: |
|
|
| oib111 wrote: | | Ok, well, now I really need to know how to close a process. | WM_QUIT I believe. If you want to terminate it, use ::TerminateProcess.
My example is working btw (w/ notepad at least)...
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Sep 14, 2007 7:51 pm Post subject: |
|
|
hidden process, such as idk, lets take something from task manager. Ah, like if I watned to close nvsvc32.exe, how?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Fri Sep 14, 2007 7:54 pm Post subject: |
|
|
| going by the name "nvsvc32.exe" I'm guessing it's a service. To stop that you would go through the service control manager (ControlService with SERVICE_CONTROL_STOP)
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Sep 14, 2007 8:08 pm Post subject: |
|
|
how about if i just made a program and made it a hidden process and made it not have a window, what would i do to close it from another program? Btw, is there anyway to take a program and make it a child window to your program so you can access its info + close it?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Fri Sep 14, 2007 8:27 pm Post subject: |
|
|
| yes, set up pipes for communication and when you want it to close you can send it a message that the program will interpret as close.
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Sep 14, 2007 9:36 pm Post subject: |
|
|
ok, but how i delete files in C++?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Fri Sep 14, 2007 9:37 pm Post subject: |
|
|
| with the aptly named DeleteFile function.
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Sep 14, 2007 9:38 pm Post subject: |
|
|
ooo fast responder , lol , thx
edit:
| Code: |
DeleteFile("bla.txt");
|
or
| Code: |
DeleteFile("C:\Documents and Settings\OIB\Desktop\bla.txt");
|
I mean I know it says filename, but what if you have more than one file with the same name? Wouldn't you need file path?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Fri Sep 14, 2007 9:44 pm Post subject: |
|
|
| You can't have two files with the same name in the same directory. Use the full path.
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Sep 14, 2007 9:48 pm Post subject: |
|
|
I know, but what if you had two files named the same thing but in different directories, would it delete both?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Fri Sep 14, 2007 9:51 pm Post subject: |
|
|
| oib111 wrote: | | I know, but what if you had two files named the same thing but in different directories, would it delete both? |
No, of course not.
How the hell would: DeleteFile("C:\\path\\path\\path\\file.txt");
delete "C:\file.txt"
|
|
| Back to top |
|
 |
|