-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathForm1.twin
More file actions
60 lines (49 loc) · 2.09 KB
/
Form1.twin
File metadata and controls
60 lines (49 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
[Description("")]
[FormDesignerId("CF225592-F05B-4F47-9EAB-EDCD086F9191")]
[PredeclaredId]
Class Form1
Private Sub Command1_Click() Handles Command1.Click
Dim pPicker As IDsObjectPicker
Dim hr As Long
hr = CoCreateInstance(CLSID_DsObjectPicker, Nothing, CLSCTX_ALL, IID_IDsObjectPicker, pPicker)
If FAILED(hr) Then
Debug.Print "Failed to create CLSID_DsObjectPicker, 0x" & Hex$(hr)
Exit Sub
End If
Dim info As DSOP_INIT_INFO
info.cbSize = LenB(Of DSOP_INIT_INFO)
info.cDsScopeInfos = 1
Dim scope As DSOP_SCOPE_INIT_INFO
scope.cbSize = LenB(Of DSOP_SCOPE_INIT_INFO)
scope.flType = DSOP_SCOPE_TYPE_WORKGROUP Or DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN Or DSOP_SCOPE_TYPE_ENTERPRISE_DOMAIN
scope.flScope = DSOP_SCOPE_FLAG_DEFAULT_FILTER_COMPUTERS
scope.FilterFlags.flDownlevel = DSOP_DOWNLEVEL_FILTER_COMPUTERS
info.aDsScopeInfos = VarPtr(scope)
pPicker.Initialize(info)
Dim spData As IDataObject
pPicker.InvokeDialog(Me.hWnd, spData)
If (spData Is Nothing) Or (FAILED(Err.LastHresult)) Then
Debug.Print "InvokeDialog failed, 0x" & Hex$(Err.LastHresult)
Exit Sub
End If
Dim fmt As FORMATETC
fmt.cfFormat = DCast(Of Integer)(RegisterClipboardFormat(CFSTR_DSOP_DS_SELECTION_LIST))
fmt.dwAspect = DVASPECT_CONTENT
fmt.tymed = TYMED_HGLOBAL
fmt.lIndex = -1
Dim med As STGMEDIUM
hr = spData.GetData(fmt, med)
If FAILED(hr) Then
Debug.Print "Failed to retrieve computer name, 0x" & Hex$(hr)
Exit Sub
End If
Dim data As LongPtr = GlobalLock(med.data)
With CType(Of DS_SELECTION_LIST)(data)
Dim sRes As String
sRes = LPWSTRtoStr(.aDsSelection(0).pwzName, False)
End With
Text1.Text = sRes
GlobalUnfix(med.data)
ReleaseStgMedium(med)
End Sub
End Class