Update of /cvsroot/pywin32/pywin32/win32/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6403/win32/src
Modified Files:
win32process.i
Log Message:
Add GetProcessId
Index: win32process.i
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32process.i,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** win32process.i 24 Feb 2007 00:29:07 -0000 1.27
--- win32process.i 6 Mar 2007 19:44:06 -0000 1.28
***************
*** 26,29 ****
--- 26,31 ----
typedef DWORD (WINAPI *GetModuleFileNameExfunc)(HANDLE, HMODULE, WCHAR *, DWORD);
static GetModuleFileNameExfunc pfnGetModuleFileNameEx = NULL;
+ typedef DWORD (WINAPI *GetProcessIdfunc)(HANDLE);
+ static GetProcessIdfunc pfnGetProcessId = NULL;
#ifndef MS_WINCE
***************
*** 932,935 ****
--- 934,955 ----
"UserTime", PyLong_FromUnsignedLongLong(usertime.QuadPart));
}
+
+ // @pyswig int|GetProcessId|Returns the Pid for a process handle
+ static PyObject *PyGetProcessId(PyObject *self, PyObject *args)
+ {
+ CHECK_PFN(GetProcessId);
+ PyObject *obhprocess;
+ HANDLE hprocess;
+ DWORD pid;
+ if (!PyArg_ParseTuple(args, "O:GetProcessId",
+ &obhprocess)) // @pyparm <o PyHANDLE>|Process||Handle to a process
+ return NULL;
+ if (!PyWinObject_AsHANDLE(obhprocess, &hprocess, FALSE))
+ return NULL;
+ pid=(*pfnGetProcessId)(hprocess);
+ if (pid==0)
+ return PyWin_SetAPIError("GetProcessId");
+ return PyLong_FromUnsignedLong(pid);
+ }
%}
%native (GetProcessPriorityBoost) PyGetProcessPriorityBoost;
***************
*** 939,942 ****
--- 959,963 ----
%native (GetThreadIOPendingFlag) PyGetThreadIOPendingFlag;
%native (GetThreadTimes) PyGetThreadTimes;
+ %native (GetProcessId) PyGetProcessId;
#ifndef MS_WINCE
***************
*** 1513,1516 ****
--- 1534,1538 ----
pfnSetThreadIdealProcessor=(SetThreadIdealProcessorfunc)GetProcAddress(hmodule,"SetThreadIdealProcessor");
pfnSetProcessAffinityMask=(SetProcessAffinityMaskfunc)GetProcAddress(hmodule,"SetProcessAffinityMask");
+ pfnGetProcessId=(GetProcessIdfunc)GetProcAddress(hmodule, "GetProcessId");
}
|