0001 """A COM Server which exposes the NT Performance monitor in a very rudimentary way 0002 0003 Usage from VB: 0004 set ob = CreateObject("Python.PerfmonQuery") 0005 freeBytes = ob.Query("Memory", "Available Bytes") 0006 """ 0007 from win32com.server import exception, register 0008 import pythoncom, win32pdhutil, winerror 0009 0010 class PerfMonQuery: 0011 _reg_verprogid_ = "Python.PerfmonQuery.1" 0012 _reg_progid_ = "Python.PerfmonQuery" 0013 _reg_desc_ = "Python Performance Monitor query object" 0014 _reg_clsid_ = "{64cef7a0-8ece-11d1-a65a-00aa00125a98}" 0015 _reg_class_spec_ = "win32com.servers.perfmon.PerfMonQuery" 0016 _public_methods_ = [ 'Query' ] 0017 def Query(self, object, counter, instance = None, machine = None): 0018 try: 0019 return win32pdhutil.GetPerformanceAttributes(object, counter, instance, machine=machine) 0020 except win32pdhutil.error, (rc, fn, desc): 0021 raise exception.Exception(desc=desc) 0022 except TypeError, desc: 0023 raise exception.Exception(desc=desc,scode=winerror.DISP_E_TYPEMISMATCH) 0024 0025 if __name__=='__main__': 0026 print "Registering COM server..." 0027 register.UseCommandLine(PerfMonQuery) 0028
Generated by PyXR 0.9.4