[pywin32-checkins] pywin32/win32/src win32pdhmodule.cpp,1.12,1.13
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2007-01-20 17:44:27
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13775/win32/src Modified Files: win32pdhmodule.cpp Log Message: Change places where Query and Counter handles treated as ints Index: win32pdhmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32pdhmodule.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** win32pdhmodule.cpp 1 Nov 2006 15:47:39 -0000 1.12 --- win32pdhmodule.cpp 20 Jan 2007 17:44:26 -0000 1.13 *************** *** 443,454 **** { HQUERY hQuery; PyObject *obPath; DWORD userData = 0; ! if (!PyArg_ParseTuple(args, "iO|i:AddCounter", ! &hQuery, // @pyparm int|hQuery||Handle to an open query. &obPath, // @pyparm string|path||Full path to the performance data &userData)) // @pyparm int|userData|0|User data associated with the counter. return NULL; ! TCHAR *szPath; if (!PyWinObject_AsTCHAR(obPath, &szPath, FALSE)) --- 443,456 ---- { HQUERY hQuery; + PyObject *obhQuery; PyObject *obPath; DWORD userData = 0; ! if (!PyArg_ParseTuple(args, "OO|i:AddCounter", ! &obhQuery, // @pyparm int|hQuery||Handle to an open query. &obPath, // @pyparm string|path||Full path to the performance data &userData)) // @pyparm int|userData|0|User data associated with the counter. return NULL; ! if (!PyWinObject_AsHANDLE(obhQuery, &hQuery, FALSE)) ! return NULL; TCHAR *szPath; if (!PyWinObject_AsTCHAR(obPath, &szPath, FALSE)) *************** *** 475,480 **** { HQUERY handle; ! if (!PyArg_ParseTuple(args, "i:RemoveCounter", ! &handle)) // @pyparm int|handle||Handle to an open counter. return NULL; // @comm See also <om win32pdh.AddCounter> --- 477,485 ---- { HQUERY handle; ! PyObject *obhandle; ! if (!PyArg_ParseTuple(args, "O:RemoveCounter", ! &obhandle)) // @pyparm int|handle||Handle to an open counter. ! return NULL; ! if (!PyWinObject_AsHANDLE(obhandle, &handle, FALSE)) return NULL; // @comm See also <om win32pdh.AddCounter> *************** *** 513,517 **** if (pdhStatus != ERROR_SUCCESS) return PyWin_SetAPIError("OpenQuery", pdhStatus); ! return PyInt_FromLong((long)hQuery); // @comm See also <om win32pdh.CloseQuery> } --- 518,522 ---- if (pdhStatus != ERROR_SUCCESS) return PyWin_SetAPIError("OpenQuery", pdhStatus); ! return PyWinLong_FromHANDLE(hQuery); // @comm See also <om win32pdh.CloseQuery> } *************** *** 521,526 **** { HQUERY handle; ! if (!PyArg_ParseTuple(args, "i:CloseQuery", ! &handle)) // @pyparm int|handle||Handle to an open query. return NULL; // @comm See also <om win32pdh.OpenQuery> --- 526,534 ---- { HQUERY handle; ! PyObject *obhandle; ! if (!PyArg_ParseTuple(args, "O:CloseQuery", ! &obhandle)) // @pyparm int|handle||Handle to an open query. ! return NULL; ! if (!PyWinObject_AsHANDLE(obhandle, &handle, FALSE)) return NULL; // @comm See also <om win32pdh.OpenQuery> *************** *** 615,623 **** { HCOUNTER handle; BOOL bExplainText = TRUE; ! if (!PyArg_ParseTuple(args, "i|i:GetCounterInfo", ! &handle, // @pyparm int|handle||The handle of the item to query &bExplainText)) // @pyparm int|bRetrieveExplainText||Should explain text be retrieved? return NULL; // First call to get buffer size DWORD bufSize = 0; --- 623,634 ---- { HCOUNTER handle; + PyObject *obhandle; BOOL bExplainText = TRUE; ! if (!PyArg_ParseTuple(args, "O|i:GetCounterInfo", ! &obhandle, // @pyparm int|handle||The handle of the item to query &bExplainText)) // @pyparm int|bRetrieveExplainText||Should explain text be retrieved? return NULL; + if (!PyWinObject_AsHANDLE(obhandle, &handle, FALSE)) + return NULL; // First call to get buffer size DWORD bufSize = 0; *************** *** 675,684 **** { HCOUNTER handle; DWORD format; ! if (!PyArg_ParseTuple(args, "ii:GetFormattedCounterValue", ! &handle, // @pyparm int|handle||Handle to the counter &format)) // @pyparm int|format||Format of result. Can be PDH_FMT_DOUBLE, PDH_FMT_LARGE, PDH_FMT_LONG and or'd with PDH_FMT_NOSCALE, PDH_FMT_1000 return NULL; DWORD type; PDH_FMT_COUNTERVALUE result; --- 686,698 ---- { HCOUNTER handle; + PyObject *obhandle; DWORD format; ! if (!PyArg_ParseTuple(args, "Oi:GetFormattedCounterValue", ! &obhandle, // @pyparm int|handle||Handle to the counter &format)) // @pyparm int|format||Format of result. Can be PDH_FMT_DOUBLE, PDH_FMT_LARGE, PDH_FMT_LONG and or'd with PDH_FMT_NOSCALE, PDH_FMT_1000 return NULL; + if (!PyWinObject_AsHANDLE(obhandle, &handle, FALSE)) + return NULL; DWORD type; PDH_FMT_COUNTERVALUE result; *************** *** 712,719 **** { HQUERY hQuery; ! if (!PyArg_ParseTuple(args, "i:CollectQueryData", ! &hQuery)) // @pyparm int|hQuery||Handle to an open query. return NULL; - CHECK_PDH_PTR(pPdhCollectQueryData); PDH_STATUS pdhStatus; --- 726,735 ---- { HQUERY hQuery; ! PyObject *obhQuery; ! if (!PyArg_ParseTuple(args, "O:CollectQueryData", ! &obhQuery)) // @pyparm int|hQuery||Handle to an open query. ! return NULL; ! if (!PyWinObject_AsHANDLE(obhQuery, &hQuery, FALSE)) return NULL; CHECK_PDH_PTR(pPdhCollectQueryData); PDH_STATUS pdhStatus; *************** *** 872,881 **** { HCOUNTER hCounter; LONG lFactor; ! if (!PyArg_ParseTuple(args, "il:SetCounterScaleFactor", ! &hCounter, // @pyparm int|hCounter||Handle to the counter. &lFactor)) // @pyparm int|factor||power of ten used to multiply value. return NULL; ! CHECK_PDH_PTR(pPdhSetCounterScaleFactor); PyW32_BEGIN_ALLOW_THREADS --- 888,899 ---- { HCOUNTER hCounter; + PyObject *obhCounter; LONG lFactor; ! if (!PyArg_ParseTuple(args, "Ol:SetCounterScaleFactor", ! &obhCounter, // @pyparm int|hCounter||Handle to the counter. &lFactor)) // @pyparm int|factor||power of ten used to multiply value. return NULL; ! if (!PyWinObject_AsHANDLE(obhCounter, &hCounter, FALSE)) ! return NULL; CHECK_PDH_PTR(pPdhSetCounterScaleFactor); PyW32_BEGIN_ALLOW_THREADS *************** *** 926,930 **** static PyObject *PyBrowseCounters(PyObject *self, PyObject *args) { ! PyObject *obFlags; PDH_BROWSE_DLG_CONFIG cfg; PDH_BROWSE_DLG_CONFIG *pcfg = &cfg; --- 944,948 ---- static PyObject *PyBrowseCounters(PyObject *self, PyObject *args) { ! PyObject *obFlags, *obhwnd; PDH_BROWSE_DLG_CONFIG cfg; PDH_BROWSE_DLG_CONFIG *pcfg = &cfg; *************** *** 932,943 **** // Note - this has set caption and others to default of zero. memset(&cfg, 0, sizeof(cfg)); ! if (!PyArg_ParseTuple(args, "OiOi|z:BrowseCounters", &obFlags, // @pyparm tuple|flags||Tuple describing the bitmasks, or None. ! &pcfg->hWndOwner, // @pyparm int|hWnd||parent for the dialog. &myCfg.func, // @pyparm object|callback||A callable object to function as the callback. &pcfg->dwDefaultDetailLevel, // @pyparm int|defDetailLevel||The default detail level to show on startup in the Detail Level combo box. If the Detail Level combo box is not shown, this is the detail level to use in filtering the displayed performance counters and objects. &pcfg->szDialogBoxCaption)) // @pyparm string|dlgCaption||The dialog coption, or None for default. return NULL; ! if (!PyCallable_Check(myCfg.func)) { PyErr_SetString(PyExc_TypeError, "The callback object must be a callable object"); --- 950,962 ---- // Note - this has set caption and others to default of zero. memset(&cfg, 0, sizeof(cfg)); ! if (!PyArg_ParseTuple(args, "OOOi|z:BrowseCounters", &obFlags, // @pyparm tuple|flags||Tuple describing the bitmasks, or None. ! &obhwnd, // @pyparm <o PyHANDLE>|hWnd||parent for the dialog. &myCfg.func, // @pyparm object|callback||A callable object to function as the callback. &pcfg->dwDefaultDetailLevel, // @pyparm int|defDetailLevel||The default detail level to show on startup in the Detail Level combo box. If the Detail Level combo box is not shown, this is the detail level to use in filtering the displayed performance counters and objects. &pcfg->szDialogBoxCaption)) // @pyparm string|dlgCaption||The dialog coption, or None for default. return NULL; ! if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&pcfg->hWndOwner, FALSE)) ! return NULL; if (!PyCallable_Check(myCfg.func)) { PyErr_SetString(PyExc_TypeError, "The callback object must be a callable object"); |