GetPidByHandle

DWORD WINAPI GetPidByHandle(HANDLE hProcess)
{
    NTSTATUS nStatus = STATUS_UNSUCCESSFUL;
    DWORD      dwRel = 0;
    PROCESS_BASIC_INFORMATION ProcessInfo;

    RtlZeroMemory(&ProcessInfo, sizeof(ProcessInfo));
    nStatus = NtQueryInfomationProcess(hProcess, ProcessBasicInformation, &ProcessInfo,
    sizeof(PROCESS_BASIC_INFORMATION), NULL);

    if(NT_SUCCESS(nStatus))
    {
        dwRel= (DWORD)ProcessInfo.uUniqueProcessId;
    }

   return dwRel;
    }
}

你可能感兴趣的:(GetPidByHandle)