def FindPerformanceAttributesByName(instanceName, object = None,
                                    counter = None,
                                    format = win32pdh.PDH_FMT_LONG,
                                    machine = None, bRefresh=0):
    """Find peformance attributes by (case insensitive) instance name.

    Given a process name, return a list with the requested attributes.
    Most useful for returning a tuple of PIDs given a process name.
    """
    if object is None: object = find_pdh_counter_localized_name("Process", machine)
    if counter is None: counter = find_pdh_counter_localized_name("ID Process", machine)
    if bRefresh: # PDH docs say this is how you do a refresh.
        win32pdh.EnumObjects(None, machine, 0, 1)
    instanceName = string.lower(instanceName)
    items, instances = win32pdh.EnumObjectItems(None,None,object, -1)
    # Track multiple instances.
    instance_dict = {}
    for instance in instances:
        try:
            instance_dict[instance] = instance_dict[instance] + 1
        except __HOLE__:
            instance_dict[instance] = 0

    ret = []
    for instance, max_instances in instance_dict.items():
        for inum in xrange(max_instances+1):
            if string.lower(instance) == instanceName:
                ret.append(GetPerformanceAttributes(object, counter,
                                                    instance, inum, format,
                                                    machine))
    return ret
dataset/ETHPy150Open deanhiller/databus/webapp/play1.3.x/python/Lib/site-packages/win32/lib/win32pdhutil.py/FindPerformanceAttributesByName