Link to home
Start Free TrialLog in
Avatar of BMezzenga
BMezzenga

asked on

Using API to cancel Window Task

How do I use API to find out if a particular task (for example PCAnywhere script) is currently running and is listed in Windows Task List.

Once I do find out that it's running, how do I use API to end it.
Avatar of BMezzenga
BMezzenga

ASKER

By the way, I am talking about Windows 98 and VB6.
Just a bit of extra info.
does pcanywhere have an open window or does it only show in the task list?



Try this
Http://www.mvps.org/vb/code/tasklist.zip


and to kill the process

'Declarations
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_CLOSE = &H10  


PostMessage List1.ItemData(List1.ListIndex), WM_CLOSE, 0, 0
you can use the findwindow api to look for a specific task.
only if you know the EXACT window title
Sage, I am not looking for only one window but a whole process and also child processes which may spawn from it.

eg. PcAnywhere script may be designed to call other computers in which case it may have other windows open when it's dialing

Jetforce, the web site which you gave me does not work. Can you please check if it's correct.
Adjusted points from 100 to 150
http://www.winmag.com/columns/powertools/ptwinwatch.htm

that should return all those child windows too.  it includes the window handle so you should be able to terminate processes as needed as well
I am trying to use API because this is something that VB is supposed to do while I am not there.

At a certain time, VB program is meant to check what processes are running and then if it finds a perticular task it's looking for, it's supposed to end it.

I don't need tools to show me as a user how to close tasks, I need the program to do it itself.

That's why I am looking for an API.
Adjusted points from 150 to 200
and how do you plan to find this task? by executable name?  by window title? it depends on what info you are going to send the program
OK, I don't know what can be returned from the task list to identify a program.
I am not sure if there is a handle which can be returned or name or whatever.

Therefore my first question is:

Is it possible to get the API to return a list of executables by name as they are listed in the Ctrl+Alt+Del (Task list window).

For Example

PCAnywhere
Explorer
SysTray
Program X
Program Y
Program Z
etc........
ASKER CERTIFIED SOLUTION
Avatar of AzraSound
AzraSound
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'll try it out and I'll let you know how it went. Thanks.
The program you gave me works. I also found anohter one on the net which actually selects a task and terminates it as well.

But your program got me there half way, by displaying the running tasks.

Thanks for your help.