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.

76 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 "nt.h"
  12. #include "ntpsapi.h"
  13. #include "windef.h"
  14. #include "winerror.h"
  15. DWORD
  16. GetProcessId(
  17. IN HANDLE ProcessHandle,
  18. OUT LPDWORD ProcessId
  19. )
  20. /*++
  21. Routine Description:
  22. Get the process Id for a process, given its process handle.
  23. Arguments:
  24. ProcessHandle - the handle for the process to query.
  25. ProcessId - pointer to a DWORD to receive the process Id.
  26. Return Value:
  27. ERROR_SUCCESS if successful.
  28. ERROR_INVALID_PARAMETER on error.
  29. --*/
  30. {
  31. DWORD status;
  32. DWORD returnLength;
  33. PROCESS_BASIC_INFORMATION basicProcessInfo;
  34. //
  35. // Find the process id.
  36. //
  37. status = NtQueryInformationProcess( ProcessHandle,
  38. ProcessBasicInformation,
  39. &basicProcessInfo,
  40. sizeof(PROCESS_BASIC_INFORMATION),
  41. &returnLength );
  42. if ( !NT_SUCCESS(status) ) {
  43. *ProcessId = 0;
  44. return(ERROR_INVALID_PARAMETER);
  45. }
  46. *ProcessId = (DWORD)basicProcessInfo.UniqueProcessId;
  47. return(ERROR_SUCCESS);
  48. } // GetProcessId