472,951 Members | 2,203 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 software developers and data experts.

code to kill App

Hi,

How do I kill a process in xp? It is really anoying. I have the code. I
suspect that I don't have permission to do it.

What is wrong with it?
HANDLE hProcess;
PROCESSENTRY32 pe32;
CString cstrProcess;
CString app;
BOOL bResult;
cstrProcess=process;
hProcess = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

if (hProcess == INVALID_HANDLE_VALUE)
{
return (FALSE);
}

pe32.dwSize = sizeof(PROCESSENTRY32);

if (!Process32First(hProcess, &pe32))
{
CloseHandle(hProcess);

return (FALSE);
}

do
{
app=pe32.szExeFile;
if(cstrProcess==app)
{
// kill app if name matches
if(WaitForSingleObject(hProcess, 5000)
!=WAIT_OBJECT_0)
bResult = TerminateProcess(hProcess,0);
else
bResult = TRUE;
}
} while (Process32Next(hProcess, &pe32));
CloseHandle(hProcess);
return (TRUE);
Feb 26 '06 #1
1 1807
"no one" <on@one.com> schrieb im Newsbeitrag
news:5a********************@comcast.com...
Hi,

How do I kill a process in xp? It is really anoying. I have the code. I
suspect that I don't have permission to do it.

What is wrong with it?


1. If a function fails, examine the results (including documented
side-effects) to find the cause for its failure.
2. Don't use one variable for two (or more) tasks.
3. For OS related questions, OS related groups are almost allways a better
choice.

HTH
Heinz
Feb 26 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alex Hunsley | last post by:
I'm running a monitoring script under linux written in python. It's nohup'ed so that I can log out and it will continue running happily and so on, but sometimes I need to kill the script before...
10
by: Fred | last post by:
There is a setting in INIT.ORA that has the unintended side-effect of making sure the ALTER SYSTEM KILL SESSION command has immediate affect. Without this setting, I've seen some instances where...
2
by: Micky | last post by:
Can any one give me some pointers on how to kill a running procedure in DB2? I have a long running procedure called from a Java routine and after I kill the Java routine, the procedure keeps...
7
by: David Mitchell | last post by:
I use a function to read all of the files from a couple of directories (and subfolders) and update a table(tblfiles) with the fullpath and file name, the filesize and the date the file was created....
3
by: pattanawadee | last post by:
Deall All, Could anybody suggestion me How to kill all inherrit processes (sibling child,previous and parent process) in the case I know only child process id and user id, For example I strart...
1
by: Alexander N. Spitzer | last post by:
I am trying to write a program that will fork a process, and execute the given task... the catch is that if it runs too long, I want to clean it up. this seemed pretty straight forward with a...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
2
by: Matthew Wilson | last post by:
In this code, I tried to kill my thread object by setting a variable on it to False. Inside the run method of my thread object, it checks a different variable. I've already rewritten this...
3
by: spectrumdt | last post by:
Hello. I am running Fedora Linux and KDE, using the Konsole command line. When coding Python, I regularly make a bug causing my program to not terminate. But how do I kill the non-terminating...
6
by: MrDeej | last post by:
Hello! I have code wich scans the through 10 computers on a LAN for files and import them into different tabels. This code aproximitly imports 10 000 files (with 1 to 20 rows of info) a day and is...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.