IsProcessCritical
TOC
Collapse the table of content
Expand the table of content

IsProcessCritical function

Determines whether the specified process is considered critical.

Syntax


BOOL WINAPI IsProcessCritical(
  _In_  HANDLE hProcess,
  _Out_ PBOOL  Critical
);

Parameters

hProcess [in]

A handle to the process to query. The process must have been opened with PROCESS_QUERY_LIMITED_INFORMATION access.

Critical [out]

A pointer to the BOOL value this function will use to indicate whether the process is considered critical.

Return value

This routine returns FALSE on failure. Any other value indicates success. Call GetLastError to query for the specific error reason on failure.

Examples

The following example queries whether the current process is critical:



// Handle to the process to query.
HANDLE h(NULL);

// Variable to store the result.
BOOL crit(FALSE);

// This example queries the current process.
h = GetCurrentProcess();

// Check whether the process is critical.
BOOL success = IsProcessCritical(h, &crit);

// If the function call failed, check the error code.
if (!success)
{
    DWORD error = GetLastError();
    HRESULT hr = HRESULT_FROM_WIN32(error);
    
    if (FAILED(hr))
    {
        OutputDebugStringW(L"Process cannot be queried.");
    } 
}
else
{
    // Otherwise, use the result.
    if (crit)
    {
        OutputDebugStringW(L"Process is critical!");
    }
    else
    {
        OutputDebugStringW(L"Process is not critical.");
    }
}

Requirements

Minimum supported client

Windows 8.1 [desktop apps only]

Minimum supported server

Windows Server 2012 R2 [desktop apps only]

Header

Processthreadsapi.h

Library

Kernel32.lib

DLL

Ntdll.dll

See also

HRESULT_FROM_WIN32

 

 

Show:
© 2016 Microsoft