Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

objectPicker.py 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # A demo for the IDsObjectPicker interface.
  2. import pythoncom
  3. import win32clipboard
  4. from win32com.adsi import adsi
  5. from win32com.adsi.adsicon import *
  6. cf_objectpicker = win32clipboard.RegisterClipboardFormat(CFSTR_DSOP_DS_SELECTION_LIST)
  7. def main():
  8. hwnd = 0
  9. # Create an instance of the object picker.
  10. picker = pythoncom.CoCreateInstance(
  11. adsi.CLSID_DsObjectPicker,
  12. None,
  13. pythoncom.CLSCTX_INPROC_SERVER,
  14. adsi.IID_IDsObjectPicker,
  15. )
  16. # Create our scope init info.
  17. siis = adsi.DSOP_SCOPE_INIT_INFOs(1)
  18. sii = siis[0]
  19. # Combine multiple scope types in a single array entry.
  20. sii.type = (
  21. DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN | DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN
  22. )
  23. # Set uplevel and downlevel filters to include only computer objects.
  24. # Uplevel filters apply to both mixed and native modes.
  25. # Notice that the uplevel and downlevel flags are different.
  26. sii.filterFlags.uplevel.bothModes = DSOP_FILTER_COMPUTERS
  27. sii.filterFlags.downlevel = DSOP_DOWNLEVEL_FILTER_COMPUTERS
  28. # Initialize the interface.
  29. picker.Initialize(
  30. None, # Target is the local computer.
  31. siis, # scope infos
  32. DSOP_FLAG_MULTISELECT, # options
  33. ("objectGUID", "displayName"),
  34. ) # attributes to fetch
  35. do = picker.InvokeDialog(hwnd)
  36. # Extract the data from the IDataObject.
  37. format_etc = (
  38. cf_objectpicker,
  39. None,
  40. pythoncom.DVASPECT_CONTENT,
  41. -1,
  42. pythoncom.TYMED_HGLOBAL,
  43. )
  44. medium = do.GetData(format_etc)
  45. data = adsi.StringAsDS_SELECTION_LIST(medium.data)
  46. for item in data:
  47. name, klass, adspath, upn, attrs, flags = item
  48. print("Item", name)
  49. print(" Class:", klass)
  50. print(" AdsPath:", adspath)
  51. print(" UPN:", upn)
  52. print(" Attrs:", attrs)
  53. print(" Flags:", flags)
  54. if __name__ == "__main__":
  55. main()