Click here to Skip to main content
15,881,812 members
Articles / Desktop Programming / MFC

Get Process Info with NtQueryInformationProcess

Rate me:
Please Sign up or sign in to vote.
4.70/5 (13 votes)
21 Jul 2007CPOL6 min read 188.1K   13.1K   71  
Get process parent ID, command-line, etc.
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

/** Unicode Support
#pragma warning(disable : 4995)	// 'function': name was marked as #pragma deprecated

// Compile with UNICODE support
#ifndef _UNICODE	// C Unicode support
#define _UNICODE
#endif

#ifndef UNICODE		// Win32 API Unicode support
#define UNICODE
#endif

**/

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER				// Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0500		// Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINNT		// Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0500		// Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif						

#ifndef _WIN32_WINDOWS		// Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0490 // Change this to the appropriate value to target Windows Me or later.
#endif

//#ifndef _WIN32_IE			// Allow use of features specific to IE 4.0 or later.
//#define _WIN32_IE 0x0600	// Change this to the appropriate value to target IE 5.0 or later.
//#endif

#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
// C RunTime Header Files
#ifdef _DEBUG
#define CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#else
#include <stdlib.h>
#endif

//#include <malloc.h>
//#include <memory.h>
#include <tchar.h>

// TODO: reference additional headers your program requires here
#include <commctrl.h>

#pragma comment(lib, "comctl32.lib")


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
Steven Moore is a self-taught programmer on and off over the last 20+ years. He programmed in BASIC, Microsoft Visual Basic for Applications (VBA), Wang COBOL, a little Wang ASM, JavaScript, a little in C++ with inline ASM and Python 3.x. First article was GetNtProcessInfo on this site.

Comments and Discussions