objectPicker.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:remoteControlPPT 作者: htwenning 项目源码 文件源码
def main(): 
    hwnd = 0

    # Create an instance of the object picker. 
    picker = pythoncom.CoCreateInstance(adsi.CLSID_DsObjectPicker,
                                None,
                                pythoncom.CLSCTX_INPROC_SERVER,
                                adsi.IID_IDsObjectPicker)

    # Create our scope init info.
    siis = adsi.DSOP_SCOPE_INIT_INFOs(1)
    sii = siis[0]

    # Combine multiple scope types in a single array entry.

    sii.type = DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN | \
               DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN

    # Set uplevel and downlevel filters to include only computer objects.
    # Uplevel filters apply to both mixed and native modes.
    # Notice that the uplevel and downlevel flags are different.

    sii.filterFlags.uplevel.bothModes = DSOP_FILTER_COMPUTERS
    sii.filterFlags.downlevel = DSOP_DOWNLEVEL_FILTER_COMPUTERS

    # Initialize the interface.
    picker.Initialize(
        None, # Target is the local computer.
        siis, # scope infos
        DSOP_FLAG_MULTISELECT, # options
        ('objectGUID','displayName') ) # attributes to fetch

    do = picker.InvokeDialog(hwnd)
    # Extract the data from the IDataObject.
    format_etc = (cf_objectpicker, None,
                  pythoncom.DVASPECT_CONTENT, -1,
                  pythoncom.TYMED_HGLOBAL)
    medium = do.GetData(format_etc)
    data = adsi.StringAsDS_SELECTION_LIST(medium.data)
    for item in data:
        name, klass, adspath, upn, attrs, flags = item
        print "Item", name
        print " Class:", klass
        print " AdsPath:", adspath
        print " UPN:", upn
        print " Attrs:", attrs
        print " Flags:", flags
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号