That works for XP but not Vista, I guess M$ changed the API in Vista. Oh by the way I mean to write win32pdhutil.browse() earlier. Thanks for the help.<br>I didn't run it as admin in Vista before so I gave your script a try.
<br>The output from your script as run in vista by administrator follows:
<br>[code]<br>>>> win32pdhutil.browse()<br>Value of '\Network Interface(Intel[R] PRO_100 VE Network Connection)\Current Bandwidth' is 100000000.0<br>Added 'Current Bandwidth' on object 'Network Interface' (machine \\SAIBOX-01), instance Intel[R] PRO_100 VE Network Connection(0)-parent of None
<br>>>> <br>Traceback (most recent call last):<br> File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript<br> exec codeObject in __main__.__dict__<br>
File "C:\Python25\getrcv.py", line 10, in <module>
<br> tp,val = win32pdh.GetFormattedCounterValue( hc, win32pdh.PDH_FMT_LONG )<br>error: (-1073738810, 'GetFormattedCounterValue', 'No error message is available')<br>>>> <br>[/code]<br>I'm new to working in windows and am curious as to how to go about getting the error codes, I tried hex(1073738810) but thats not right.
<br> <br><br>
<div class="gmail_quote">On Jan 23, 2008 1:11 PM, Tim Roberts <<a href="mailto:timr@probo.com" target="_blank">timr@probo.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div> >.> wrote:<br>> I got the interface name from win32util.browse() in Vista and XP. I<br>> think XP is Giving me the wrong number because it differs from what<br>> I'm reading in perfmon everytime and it seems to be counting down from
<br>> that number after every subsequent call.<br>> ex: perfmon will give me a last of 0.0 and<br>> win32pdhutil.GetPerformanceAttributes('Network Interface','Bytes<br>> Received/sec','Intel[R] PRO_100 VE Network Connection - Packet
<br>> Scheduler Miniport')<br>><br>> Will return something like 12107 and will go down every subsequent call.<br><br></div></div>Insert a call to win32pdh.CollectQueryData(hq) before you fetch the<br>counter value. The counters are only fetched when you send a query, and
<br>that's done with CollectQueryData.<br><br>For me, this produces exactly the same numbers as perfmon:<br><br>import win32pdh<br>import time<br>intf = "NVIDIA nForce Networking Controller - Packet Scheduler Miniport"
<br>hq = win32pdh.OpenQuery()<br>cp = win32pdh.MakeCounterPath( (None, 'Network Interface', intf, None,<br>-1, 'Bytes Received/sec') )<br>hc = win32pdh.AddCounter( hq, cp )<br>for i in range(100):<br>
win32pdh.CollectQueryData
( hq )<br> tp,val = win32pdh.GetFormattedCounterValue( hc, win32pdh.PDH_FMT_LONG )<br> print hex(tp),val<br> time.sleep(1)<br><font color="#888888"><br>--<br>Tim Roberts, <a href="mailto:timr@probo.com" target="_blank">
timr@probo.com
</a><br>Providenza & Boekelheide, Inc.<br></font><div><div></div><div><br>_______________________________________________<br>python-win32 mailing list<br><a href="mailto:python-win32@python.org" target="_blank">python-win32@python.org
</a><br><a href="http://mail.python.org/mailman/listinfo/python-win32" target="_blank">http://mail.python.org/mailman/listinfo/python-win32</a><br></div></div></blockquote></div><br>