Windows API - program ID's
BlitzMax Forums/BlitzMax Programming/Windows API - program ID's
| ||
I am trying to come up with a way to kill specific processes, and cobbled together the following which is largely based on something by Sweenie... However, I am running into a snag that the PID returned by the code does not match up with the actual PID used by the program as shown by TaskManager. If I use the taskmanager PID's I can successfully terminate a process, but for whatever reasons the PID's returned by the program below seem to be off a couple... Most of the time the returned value is off by 4, but it's not consistent -- sometimes it's off by 8, or even more than a hundred. There's definitely something not right, but for the life of me I can't figure out what it is. Is there anyone who can offer some pointers to what I'm doing wrong? |
| ||
Use pub.freeprocess. |
| ||
(Oops, looks like my initial posting got chopped off. Fixed) Use pub.freeprocess I looked at that, but didn't see a way to kill an arbitrary process that wasn't launched through Blitzmax itself first... The problem is getting the process ID for the other program, not killing the process once I have it. |
| ||
@xlsior: I'm not sure if vista will let any application terminate a process it has not started... I think it will be considered a security violation by the OS. |
| ||
I'm not sure if vista will let any application terminate a process it has not started... I think it will be considered a security violation by the OS. You're probably right, but this is for something I'm mainly writing for personal use, and I have no intention of downgrading to Vista any time soon... And killing the process works fine with the code above under XP, the only problem I have is to programmatically get the correct process ID. If I look it up in taskmanager and feed that to the KillProcess function, it works like a charm. |
| ||
lpdwProcessId param returns the Process ID that you need to use. The one you was using is a Thread ID. |
| ||
Aha! thank you so much! The Win32 API sure isn't very easy to get started with. :-? |
| ||
np mate |