[pywin32-checkins] pywin32/win32/src win32pdhmodule.cpp, 1.17.2.2, 1.17.2.3
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2008-09-28 23:38:21
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7575 Modified Files: Tag: py3k win32pdhmodule.cpp Log Message: Load either ansi or wide character pdh functions Update parameters to PdhOpenQuery Index: win32pdhmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32pdhmodule.cpp,v retrieving revision 1.17.2.2 retrieving revision 1.17.2.3 diff -C2 -d -r1.17.2.2 -r1.17.2.3 *** win32pdhmodule.cpp 28 Sep 2008 19:55:46 -0000 1.17.2.2 --- win32pdhmodule.cpp 28 Sep 2008 23:38:08 -0000 1.17.2.3 *************** *** 57,62 **** typedef PDH_STATUS (WINAPI * FuncPdhOpenQuery)( ! LPVOID pReserved, // DataSource ! DWORD dwUserData, // a value associated with this query HQUERY *phQuery // pointer to a buffer that will receive the query handle ) ; --- 57,62 ---- typedef PDH_STATUS (WINAPI * FuncPdhOpenQuery)( ! LPCTSTR szDataSource, // DataSource ! DWORD_PTR dwUserData, // a value associated with this query HQUERY *phQuery // pointer to a buffer that will receive the query handle ) ; *************** *** 184,190 **** static PyObject *win32pdh_counter_error; ! // ??? Loads all wide-character versions of the functions. Should either ! // have a way to switch between *A and *W functions as win32api does, or ! // change all TCHAR to explicit WCHAR ??? BOOL LoadPointers() { --- 184,194 ---- static PyObject *win32pdh_counter_error; ! // Select whether to load ansi or unicode API functions ! #ifdef UNICODE ! #define A_OR_W "W" ! #else ! #define A_OR_W "A" ! #endif ! BOOL LoadPointers() { *************** *** 194,216 **** return FALSE; } ! pPdhEnumObjects = (FuncPdhEnumObjects)GetProcAddress(handle, "PdhEnumObjectsW"); ! pPdhEnumObjectItems = (FuncPdhEnumObjectItems)GetProcAddress(handle, "PdhEnumObjectItemsW"); pPdhCloseQuery = (FuncPdhCloseQuery)GetProcAddress(handle, "PdhCloseQuery"); pPdhRemoveCounter = (FuncPdhRemoveCounter)GetProcAddress(handle, "PdhRemoveCounter"); ! pPdhOpenQuery = (FuncPdhOpenQuery)GetProcAddress(handle, "PdhOpenQuery"); ! pPdhAddCounter = (FuncPdhAddCounter)GetProcAddress(handle, "PdhAddCounterW"); ! pPdhMakeCounterPath = (FuncPdhMakeCounterPath)GetProcAddress(handle, "PdhMakeCounterPathW"); ! pPdhGetCounterInfo = (FuncPdhGetCounterInfo)GetProcAddress(handle, "PdhGetCounterInfoW"); pPdhGetFormattedCounterValue = (FuncPdhGetFormattedCounterValue)GetProcAddress(handle, "PdhGetFormattedCounterValue"); pPdhCollectQueryData = (FuncPdhCollectQueryData)GetProcAddress(handle, "PdhCollectQueryData"); ! pPdhValidatePath = (FuncPdhValidatePath)GetProcAddress(handle, "PdhValidatePathW"); ! pPdhExpandCounterPath = (FuncPdhExpandCounterPath)GetProcAddress(handle, "PdhExpandCounterPathW"); ! pPdhParseCounterPath = (FuncPdhParseCounterPath)GetProcAddress(handle, "PdhParseCounterPathW"); pPdhSetCounterScaleFactor = (FuncPdhSetCounterScaleFactor)GetProcAddress(handle, "PdhSetCounterScaleFactor"); ! pPdhParseInstanceName = (FuncPdhParseInstanceName)GetProcAddress(handle, "PdhParseInstanceNameW"); ! pPdhBrowseCounters = (FuncPdhBrowseCounters)GetProcAddress(handle, "PdhBrowseCountersW"); ! pPdhConnectMachine = (FuncPdhConnectMachine)GetProcAddress(handle, "PdhConnectMachineW"); ! pPdhLookupPerfNameByIndex = (FuncPdhLookupPerfNameByIndex)GetProcAddress(handle, "PdhLookupPerfNameByIndexW"); ! pPdhLookupPerfIndexByName = (FuncPdhLookupPerfIndexByName)GetProcAddress(handle, "PdhLookupPerfIndexByNameW"); // Pdh error codes are in 2 different ranges --- 198,220 ---- return FALSE; } ! pPdhEnumObjects = (FuncPdhEnumObjects)GetProcAddress(handle, "PdhEnumObjects" A_OR_W); ! pPdhEnumObjectItems = (FuncPdhEnumObjectItems)GetProcAddress(handle, "PdhEnumObjectItems" A_OR_W); pPdhCloseQuery = (FuncPdhCloseQuery)GetProcAddress(handle, "PdhCloseQuery"); pPdhRemoveCounter = (FuncPdhRemoveCounter)GetProcAddress(handle, "PdhRemoveCounter"); ! pPdhOpenQuery = (FuncPdhOpenQuery)GetProcAddress(handle, "PdhOpenQuery" A_OR_W); ! pPdhAddCounter = (FuncPdhAddCounter)GetProcAddress(handle, "PdhAddCounter" A_OR_W); ! pPdhMakeCounterPath = (FuncPdhMakeCounterPath)GetProcAddress(handle, "PdhMakeCounterPath" A_OR_W); ! pPdhGetCounterInfo = (FuncPdhGetCounterInfo)GetProcAddress(handle, "PdhGetCounterInfo" A_OR_W); pPdhGetFormattedCounterValue = (FuncPdhGetFormattedCounterValue)GetProcAddress(handle, "PdhGetFormattedCounterValue"); pPdhCollectQueryData = (FuncPdhCollectQueryData)GetProcAddress(handle, "PdhCollectQueryData"); ! pPdhValidatePath = (FuncPdhValidatePath)GetProcAddress(handle, "PdhValidatePath" A_OR_W); ! pPdhExpandCounterPath = (FuncPdhExpandCounterPath)GetProcAddress(handle, "PdhExpandCounterPath" A_OR_W); ! pPdhParseCounterPath = (FuncPdhParseCounterPath)GetProcAddress(handle, "PdhParseCounterPath" A_OR_W); pPdhSetCounterScaleFactor = (FuncPdhSetCounterScaleFactor)GetProcAddress(handle, "PdhSetCounterScaleFactor"); ! pPdhParseInstanceName = (FuncPdhParseInstanceName)GetProcAddress(handle, "PdhParseInstanceName" A_OR_W); ! pPdhBrowseCounters = (FuncPdhBrowseCounters)GetProcAddress(handle, "PdhBrowseCounters" A_OR_W); ! pPdhConnectMachine = (FuncPdhConnectMachine)GetProcAddress(handle, "PdhConnectMachine" A_OR_W); ! pPdhLookupPerfNameByIndex = (FuncPdhLookupPerfNameByIndex)GetProcAddress(handle, "PdhLookupPerfNameByIndex" A_OR_W); ! pPdhLookupPerfIndexByName = (FuncPdhLookupPerfIndexByName)GetProcAddress(handle, "PdhLookupPerfIndexByName" A_OR_W); // Pdh error codes are in 2 different ranges *************** *** 479,487 **** static PyObject *PyOpenQuery(PyObject *self, PyObject *args) { ! DWORD userData = 0; ! TCHAR *reserved = NULL; // DataSource (name of a performance log file) ! if (!PyArg_ParseTuple(args, "|zi:OpenQuery", ! &reserved, // @pyparm object|reserved|None|Must be None ! &userData)) // @pyparm int|userData|0|User data associated with the query. return NULL; --- 483,492 ---- static PyObject *PyOpenQuery(PyObject *self, PyObject *args) { ! DWORD_PTR userData = 0; ! TCHAR *DataSource = NULL; ! PyObject *obDataSource = Py_None, *obuserData = Py_None; ! if (!PyArg_ParseTuple(args, "|OO:OpenQuery", ! &obDataSource, // @pyparm str|DataSource|None|Name of a performaance log file, or None for live data ! &obuserData)) // @pyparm int|userData|0|User data associated with the query. return NULL; *************** *** 489,499 **** CHECK_PDH_PTR(pPdhOpenQuery); PDH_STATUS pdhStatus; Py_BEGIN_ALLOW_THREADS pdhStatus = (*pPdhOpenQuery) ( ! (void *)reserved, userData, &hQuery); Py_END_ALLOW_THREADS if (pdhStatus != ERROR_SUCCESS) return PyWin_SetAPIError("OpenQuery", pdhStatus); --- 494,511 ---- CHECK_PDH_PTR(pPdhOpenQuery); PDH_STATUS pdhStatus; + if (obuserData != Py_None) + if (!PyWinLong_AsDWORD_PTR(obuserData, &userData)) + return NULL; + if (!PyWinObject_AsTCHAR(obDataSource, &DataSource, TRUE)) + return NULL; + Py_BEGIN_ALLOW_THREADS pdhStatus = (*pPdhOpenQuery) ( ! DataSource, userData, &hQuery); Py_END_ALLOW_THREADS + PyWinObject_FreeTCHAR(DataSource); if (pdhStatus != ERROR_SUCCESS) return PyWin_SetAPIError("OpenQuery", pdhStatus); |