How to find out what program is running and terminate it?

How to find out what program is running and terminate it?
e.g winword.
And what if a few instance of it is running?
stlAsked:
Who is Participating?
 
alexoCommented:
Oh, why didn't you say so in the first place?

Here ya go:

#define STRICT
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#define WORD_CAPTION    "Microsoft Word"

BOOL CALLBACK FindWord(HWND hwnd, LPARAM lparam)
{
    char text[sizeof WORD_CAPTION];
    int len = GetWindowText(hwnd, text, sizeof WORD_CAPTION);
    if (len == (sizeof WORD_CAPTION - 1) && !lstrcmp(text, WORD_CAPTION))
        PostMessage(hwnd, WM_QUIT, 0, 0);
    return TRUE;
}

void main()
{
    EnumWindows(FindWord, 0);
}

0
 
alexoCommented:
If you want your program to run on Win95, you can use the ToolHelp functions.
Search for "Taking a Snapshot and Viewing Processes" in your MSVC documentation.
0
 
stlAuthor Commented:
I get a unhandled exception when I run the GetProcessList()!

Can anyone teach me how to compile the PView95 source code?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
stlAuthor Commented:
Anyway I just want to close all winword that might be running.
Any sugguestion?
0
 
stlAuthor Commented:
To alexo,
Can you teach me how to compile the PView95 source code?
Using Visual C ++ 5.

Thanks in advance.
0
 
alexoCommented:
I'm a bit stressed at work at the moment.
What seems to be the problem with the PView95 source?
If you have the makefile, just open it in the compiler and shoot.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.