unintalized local variable "exitcode" used

Can any1 explain whats wrong with GetExitCodeProcess, exitcode;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	LPDWORD exitcode;
	DWORD pid = 0;
	char wname[200];
	cout << "window name: ";
	cin >> wname;
	HWND findw = FindWindowA(0, wname);
	if (findw)
	{
		cout << endl << "Found window";
		
		GetWindowThreadProcessId(findw, &pid);

		if (pid)
		{
			cout << endl << "Process ID: " << pid << endl;
		}
	}
	else
	{
		cout << endl << "Could not find window";
	}

	////////////////////////////////////////////////////
	////////////////////////////////////////////////////
	////////////////////////////////////////////////////

	HANDLE oProc = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, pid);
	if (oProc)
	{
		cout << "Open";	
		GetExitCodeProcess(oProc, exitcode);
	}
	char f;
	cin >> f;

	return 0;
}
The error is clearly telling you whats wrong.

unintalized local variable "exitcode" used


GetExitCodeProcess(oProc, exitcode);

Here you're using exitcode, and apparently it wants you to initialize it.

LPDWORD exitcode; here
Thx TarikNeaj.
Tought the GetExitCodeProcess call will intalize exitcode as the process termination status
for me guess need listen complier than my belives :D.
Topic archived. No new replies allowed.