[python-win32] win32pdh.addcounter buggy ?

Lionel "Wagner" Barret de Nazaris lionel.bdn@free.fr
Fri, 16 Nov 2001 22:16:15 +0100


Hello everybody,

I'm currently programming a synchronizer of bookmark (synchro between
browser but also between PCs). As I was diving into the service part of the
program, I encountered a severe bug.

the win32pdh.addcounter function doesn't work (I even checked with code from
win32pdhutil.py and so on). Of course, I downloaded twice the last version
of win32all and double-checked my install. I am working under win2000 sp2
and I suppose it has something to do with the Os language.

I work on a french version of win 2000 and the counters , the objects and
the instances of the performance data handlers are in french too.
Everything is translated, so to speak.

Here follows an example of code and the error when I execute it.

##### Code
def GetPerformanceAttributes(object, counter, instance = None, inum=-1,
format = win32pdh.PDH_FMT_LONG, machine=None):
        path = win32pdh.MakeCounterPath( ("Bacchus-1",object,instance, None,
inum,counter) )
        # print path
        hq = win32pdh.OpenQuery()
        try:
                hc = win32pdh.AddCounter(hq, path)
                try:
                        win32pdh.CollectQueryData(hq)
                        type, val = win32pdh.GetFormattedCounterValue(hc,
format)
                        return val
                finally:
                        win32pdh.RemoveCounter(hc)
        finally:
                win32pdh.CloseQuery(hq)

GetPerformanceAttributes("Processus","ID Processus","IEXPLORE")

##### error
Traceback (most recent call last):
  File "C:\Documents and Settings\Administrateur.BACCHUS-1.000\Mes
documents\Projets\Bookmarker\files\test4.py", line 20, in ?
    GetPerformanceAttributes("Processus","ID Processus","IEXPLORE")
  File "C:\Documents and Settings\Administrateur.BACCHUS-1.000\Mes
documents\Projets\Bookmarker\files\test4.py", line 8, in
GetPerformanceAttributes
    hc = win32pdh.AddCounter(hq, path)
pywintypes.api_error: (-1073738823, 'AddCounter', 'No error message is
available')

So far, Nobody was able to help me. I sent a mail to M.Hammond but I fear
he's not the time to immediatly confirm the problem (or discard it as the
mistake of a half-newbie). Is it indeed a bug or did I miss some esoteric
parameters ?

thank in advance for your help, and your time,

Lionel BdN

P.S : English is not my mother tongue, so please be tolerant.