windows-nt/Source/XPSP1/NT/base/cluster/resdll/spooler/splsvc/process.cxx
2020-09-26 16:20:57 +08:00

75 lines
1.3 KiB
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*++
Copyright (c) 1992 Microsoft Corporation
Module Name:
genapp.c
Abstract:
Resource DLL for Generic Applications.
Author:
Rod Gamache (rodga) 8-Jan-1996
Revision History:
--*/
#include "precomp.h"
#pragma hdrstop
DWORD
GetProcessId(
IN HANDLE ProcessHandle,
OUT LPDWORD ProcessId
)
/*++
Routine Description:
Get the process Id for a process, given its process handle.
Arguments:
ProcessHandle - the handle for the process to query.
ProcessId - pointer to a DWORD to receive the process Id.
Return Value:
ERROR_SUCCESS if successful.
ERROR_INVALID_PARAMETER on error.
--*/
{
DWORD status;
DWORD returnLength;
PROCESS_BASIC_INFORMATION basicProcessInfo;
//
// Find the process id.
//
status = NtQueryInformationProcess( ProcessHandle,
ProcessBasicInformation,
&basicProcessInfo,
sizeof(PROCESS_BASIC_INFORMATION),
&returnLength );
if ( !NT_SUCCESS(status) ) {
*ProcessId = 0;
return(ERROR_INVALID_PARAMETER);
}
*ProcessId = basicProcessInfo.UniqueProcessId;
return(ERROR_SUCCESS);
} // GetProcessId