Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.3 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. genapp.c
  5. Abstract:
  6. Resource DLL for Generic Applications.
  7. Author:
  8. Rod Gamache (rodga) 8-Jan-1996
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. DWORD
  14. GetProcessId(
  15. IN HANDLE ProcessHandle,
  16. OUT LPDWORD ProcessId
  17. )
  18. /*++
  19. Routine Description:
  20. Get the process Id for a process, given its process handle.
  21. Arguments:
  22. ProcessHandle - the handle for the process to query.
  23. ProcessId - pointer to a DWORD to receive the process Id.
  24. Return Value:
  25. ERROR_SUCCESS if successful.
  26. ERROR_INVALID_PARAMETER on error.
  27. --*/
  28. {
  29. DWORD status;
  30. DWORD returnLength;
  31. PROCESS_BASIC_INFORMATION basicProcessInfo;
  32. //
  33. // Find the process id.
  34. //
  35. status = NtQueryInformationProcess( ProcessHandle,
  36. ProcessBasicInformation,
  37. &basicProcessInfo,
  38. sizeof(PROCESS_BASIC_INFORMATION),
  39. &returnLength );
  40. if ( !NT_SUCCESS(status) ) {
  41. *ProcessId = 0;
  42. return(ERROR_INVALID_PARAMETER);
  43. }
  44. *ProcessId = basicProcessInfo.UniqueProcessId;
  45. return(ERROR_SUCCESS);
  46. } // GetProcessId