GetProcessId(<target>)

when i try to use this function, i get a compilation error.

what can i do to fix this?
What error are you getting?

How are you calling the function? (paste the line of code that's giving the error)

Are you #including <windows.h>?

EDIT:

<semi rant>

Also... http://cplusplus.com/forum/articles/1295/

How do you expect us to tell you how to fix it when you don't show us anything you're doing?

This is like calling a car mechanic on the phone and saying "My car doesn't work. How do I fix it?" How could you expect him to know without more info or being able to see the car?

We shouldn't have to pull your teeth to get basic information about the problem out of you.

</semi rant>
Last edited on
i have included windows.h.
1
2
3
4
5
6
7
8
9
#include <iostream>
#include <windows.h>
using namespace std;
int main(int argc, char** argv) {
	DWORD pid = GetProcessId("explorer.exe");
	cout << "PID: " << pid << endl;
	return (EXIT_SUCCESS);
}


error: `GetProcessId' was not declared in this scope
That is a strange error, alright. I don't know why it's not finding GetProcessId.

You're using GetProcessId wrong anyway. You pass it a handle, not a filename. This should be giving you a compiler error (but I would think it'd be a different error than the one you're getting -- so I don't really know what's going on with that)

If you want to look up another process by its name you have to find its handle first. Here's a page I found which seems to show how to do that:

http://stackoverflow.com/questions/865152/how-can-i-get-a-process-handle-by-its-name-in-c
Topic archived. No new replies allowed.