-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrmDeviceExplorer.frm
More file actions
388 lines (366 loc) · 11 KB
/
frmDeviceExplorer.frm
File metadata and controls
388 lines (366 loc) · 11 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
'frmDeviceExplorer.frm
' Copyright (c) 2024 CM.Wang
' Freeware. Use at your own risk.
'#Region "Form"
#if defined(__FB_MAIN__) AndAlso Not defined(__MAIN_FILE__)
#define __MAIN_FILE__
#ifdef __FB_WIN32__
#cmdline "Form1.rc"
#endif
Const _MAIN_FILE_ = __FILE__
#endif
#include once "mff/Form.bi"
#include once "mff/TreeView.bi"
#include once "mff/TextBox.bi"
#include once "mff/Splitter.bi"
#include once "mff/Panel.bi"
#include once "mff/CommandButton.bi"
#include once "mff/StatusBar.bi"
#include once "mff/CheckBox.bi"
#include once "mff/ImageList.bi"
#include once "DeviceExplorer.bi"
Using My.Sys.Forms
Type frmDeviceExplorerType Extends Form
Declare Sub CommandButton_Enabled(e As Boolean)
Declare Sub CommandButton_Click(ByRef Sender As Control)
Declare Sub CheckBox_Click(ByRef Sender As CheckBox)
Declare Sub TreeView1_SelChanged(ByRef Sender As TreeView, ByRef Item As TreeNode)
Declare Sub Form_Show(ByRef Sender As Form)
Declare Sub Form_Close(ByRef Sender As Form, ByRef Action As Integer)
Declare Sub TreeView1_DblClick(ByRef Sender As Control)
Declare Constructor
Dim As TreeView TreeView1
Dim As TextBox TextBox1
Dim As Splitter Splitter1
Dim As Panel Panel1, Panel2
Dim As CommandButton cmdRefresh, cmdEnabled, cmdDisabled, cmdRemoved, cmdEject, cmdUninstall, cmdUpdate
Dim As StatusBar StatusBar1
Dim As StatusPanel StatusPanel1
Dim As CheckBox chkShowHidden, chkDarkmode, chkShowCategories
Dim As ImageList ImageList1
End Type
Constructor frmDeviceExplorerType
#if _MAIN_FILE_ = __FILE__
With App
.CurLanguagePath = ExePath & "/Languages/"
.CurLanguage = My.Sys.Language
End With
#endif
' frmDeviceExplorer
With This
.Name = "frmDeviceExplorer"
.Text = "Device Explorer"
.Designer = @This
.Caption = "Device Explorer"
.StartPosition = FormStartPosition.CenterScreen
#ifdef __USE_GTK__
This.Icon.LoadFromFile(ExePath & "DeviceExplorer.ico")
#else
This.Icon.LoadFromResourceID(1)
#endif
.OnShow = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Form), @Form_Show)
.OnClose = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Form, ByRef Action As Integer), @Form_Close)
.SetBounds 0, 0, 750, 500
End With
' TreeView1
With TreeView1
.Name = "TreeView1"
.Text = "TreeView1"
.TabIndex = 0
.Align = DockStyle.alLeft
.HideSelection = False
.ExtraMargins.Left = 10
.ExtraMargins.Top = 10
.ExtraMargins.Bottom = 10
.Sorted = True
.SelectedImages = @ImageList1
.Images = @ImageList1
.SetBounds 10, 10, 380, 419
.Designer = @This
.OnSelChanged = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As TreeView, ByRef Item As TreeNode), @TreeView1_SelChanged)
.OnDblClick = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control), @TreeView1_DblClick)
.Parent = @This
End With
' Splitter1
With Splitter1
.Name = "Splitter1"
.Text = "Splitter1"
.SetBounds 210, 0, 10, 261
.Designer = @This
.Parent = @This
End With
' Panel1
With Panel1
.Name = "Panel1"
.Text = "Panel1"
.TabIndex = 1
.Align = DockStyle.alClient
.ExtraMargins.Right = 10
.ExtraMargins.Top = 10
.ExtraMargins.Bottom = 10
.SetBounds 204, 0, 250, 261
.Designer = @This
.Parent = @This
End With
' Panel2
With Panel2
.Name = "Panel2"
.Text = "Panel2"
.TabIndex = 2
.Align = DockStyle.alBottom
.SetBounds 0, 339, 324, 80
.Designer = @This
.Parent = @Panel1
End With
' TextBox1
With TextBox1
.Name = "TextBox1"
.Text = ""
.TabIndex = 3
.Multiline = True
.ID = 1004
.ScrollBars = ScrollBarsType.Both
.Align = DockStyle.alClient
.ControlIndex = 1
.Font.Name = "Consolas"
.SetBounds 0, 0, 324, 329
.Designer = @This
.Parent = @Panel1
End With
' chkShowCategories
With chkShowCategories
.Name = "chkShowCategories"
.Text = "Show all categories"
.TabIndex = 4
.Caption = "Show all categories"
.SetBounds 0, 10, 140, 18
.Designer = @This
.Parent = @Panel2
End With
' chkShowHidden
With chkShowHidden
.Name = "chkShowHidden"
.Text = "Show hidden"
.TabIndex = 5
.Caption = "Show hidden"
.SetBounds 140, 10, 140, 18
.Designer = @This
.Parent = @Panel2
End With
' chkDarkmode
With chkDarkmode
.Name = "chkDarkmode"
.Text = "Dark mode"
.TabIndex = 6
.Caption = "Dark mode"
.Checked = True
.SetBounds 250, 10, 70, 18
.Designer = @This
.OnClick = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As CheckBox), @CheckBox_Click)
.Parent = @Panel2
End With
' cmdRefresh
With cmdRefresh
.Name = "cmdRefresh"
.Text = "Refresh"
.TabIndex = 7
.Caption = "Refresh"
.SetBounds 250, 40, 70, 20
.Designer = @This
.OnClick = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control), @CommandButton_Click)
.Parent = @Panel2
End With
' cmdEnabled
With cmdEnabled
.Name = "cmdEnabled"
.Text = "Enabled"
.TabIndex = 8
.Caption = "Enabled"
.SetBounds 0, 40, 70, 20
.Designer = @This
.OnClick = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control), @CommandButton_Click)
.Parent = @Panel2
End With
' cmdDisabled
With cmdDisabled
.Name = "cmdDisabled"
.Text = "Disabled"
.TabIndex = 9
.Caption = "Disabled"
.SetBounds 70, 40, 70, 20
.Designer = @This
.OnClick = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control), @CommandButton_Click)
.Parent = @Panel2
End With
' cmdRemoved
With cmdRemoved
.Name = "cmdRemoved"
.Text = "Removed"
.TabIndex = 10
.Caption = "Removed"
.SetBounds 140, 40, 70, 20
.Designer = @This
.OnClick = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control), @CommandButton_Click)
.Parent = @Panel2
End With
' cmdEject
With cmdEject
.Name = "cmdEject"
.Text = "Eject"
.TabIndex = 11
.Caption = "Eject"
.SetBounds 0, 59, 70, 20
.Designer = @This
.OnClick = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control), @CommandButton_Click)
.Parent = @Panel2
End With
' cmdUninstall
With cmdUninstall
.Name = "cmdUninstall"
.Text = "Uninstall"
.TabIndex = 12
.Caption = "Uninstall"
.SetBounds 70, 60, 70, 20
.Designer = @This
.OnClick = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control), @CommandButton_Click)
.Parent = @Panel2
End With
' cmdUpdate
With cmdUpdate
.Name = "cmdUpdate"
.Text = "Update"
.TabIndex = 13
.Caption = "Update"
.SetBounds 140, 60, 70, 20
.Designer = @This
.OnClick = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control), @CommandButton_Click)
.Parent = @Panel2
End With
' StatusBar1
With StatusBar1
.Name = "StatusBar1"
.Text = "StatusBar1"
.Align = DockStyle.alBottom
.SetBounds 0, 459, 764, 22
.Designer = @This
.Parent = @This
End With
' StatusPanel1
With StatusPanel1
.Name = "StatusPanel1"
.Designer = @This
.Parent = @StatusBar1
End With
' ImageList1
With ImageList1
.Name = "ImageList1"
.SetBounds 0, 0, 16, 16
.Designer = @This
.Parent = @This
End With
End Constructor
Dim Shared frmDeviceExplorer As frmDeviceExplorerType
#if _MAIN_FILE_ = __FILE__
App.DarkMode = True
frmDeviceExplorer.MainForm = True
frmDeviceExplorer.Show
App.Run
#endif
'#End Region
Private Sub frmDeviceExplorerType.CheckBox_Click(ByRef Sender As CheckBox)
App.DarkMode= Sender.Checked
InvalidateRect(0, 0, True)
End Sub
Private Sub frmDeviceExplorerType.TreeView1_SelChanged(ByRef Sender As TreeView, ByRef Item As TreeNode)
Dim i As Integer
Dim j As Integer = -1
Dim wtmp As WString Ptr
Dim wtmp2 As WString Ptr
TextBox1.Clear
Select Case Item.Hint
Case "Categories"
i = CInt(Item.Name)
StatusPanel1.Caption = Item.Hint & ": " & i
Case Else
j = CInt(Item.Name)
i = devicesIndexCategories(j)
StatusPanel1.Caption = Item.Hint & ": " & j
End Select
devicesSelected = j
TextBox1.AddLine "Categories****" & i
' TextBox1.AddLine "HDEVINFO " & categoriesHSet(i)
TextBox1.AddLine "Description " & *categoriesDescription(i)
TextBox1.AddLine "Name " & *categoriesName(i)
StringFromCLSID(@categoriesGuid(i), @wtmp)
TextBox1.AddLine "GUID " & *wtmp
If j < 0 Then
Else
TextBox1.AddLine ""
TextBox1.AddLine "Devices*******" & j
TextBox1.AddLine "FriendlyName " & *devicesFriendlyName(j)
TextBox1.AddLine "Description " & *devicesDescription(j)
TextBox1.AddLine "HardwareId " & *devicesHardwareId(j)
TextBox1.AddLine "InstanceId " & *devicesInstanceId(j)
TextBox1.AddLine "Enabled " & devicesEnabled(j)
TextBox1.AddLine "Present " & devicesPresent(j)
StringFromCLSID(devicesGUID(j), @wtmp)
TextBox1.AddLine "GUID " & *wtmp
TextBox1.AddLine ""
TextBox1.AddLine "Capabilities--(&H" & Hex(devicesCapabilities(j), 8) & ")"
TextBox1.AddLine Capabilities2Str(devicesCapabilities(j))
TextBox1.AddLine "Problem-------(&H" & Hex(devicesProblem(j), 8) & ")"
TextBox1.AddLine Problems2Str(devicesProblem(j))
TextBox1.AddLine "Status--------(&H" & Hex(devicesStatus(j), 8) & ")"
TextBox1.AddLine NodeStatus2Str(devicesStatus(j))
TextBox1.AddLine "Driver--------" & *devicesDriver(j)
GetDriverAllInformation(*devicesDriver(j), wtmp2)
TextBox1.AddLine *wtmp2
End If
CommandButton_Enabled(IIf(j < 0, False, True))
'If wtmp Then Deallocate(wtmp)
If wtmp2 Then Deallocate(wtmp2)
End Sub
Private Sub frmDeviceExplorerType.CommandButton_Enabled(e As Boolean)
cmdDisabled.Enabled = e
cmdEject.Enabled = e
cmdEnabled.Enabled = e
cmdRemoved.Enabled = e
cmdUninstall.Enabled = e
cmdUpdate.Enabled = e
End Sub
Private Sub frmDeviceExplorerType.Form_Show(ByRef Sender As Form)
pvInit()
CommandButton_Enabled(False)
App.DoEvents()
CommandButton_Click(cmdRefresh)
End Sub
Private Sub frmDeviceExplorerType.Form_Close(ByRef Sender As Form, ByRef Action As Integer)
pvRelase()
End Sub
Private Sub frmDeviceExplorerType.TreeView1_DblClick(ByRef Sender As Control)
If devicesSelected < 0 Then Exit Sub
Print pvShowPropPage(Handle, devicesSelected)
End Sub
Private Sub frmDeviceExplorerType.CommandButton_Click(ByRef Sender As Control)
If Sender.Name= "cmdRefresh" Then
pvInitIcon(@TreeView1)
pvEnumClasses(Handle, @TreeView1, chkShowCategories.Checked, chkShowHidden.Checked)
StatusPanel1.Caption = "Total: " & EnumCCount + EnumDCount & ", Categories: " & EnumCCount & ", Devices: " & EnumDCount
Else
If devicesSelected < 0 Then Exit Sub
Select Case Sender.Name
Case "cmdEnabled"
Print pvEnableDevice(Handle, devicesSelected, True, chkShowHidden.Checked)
Case "cmdDisabled"
Print pvEnableDevice(Handle, devicesSelected, False, chkShowHidden.Checked)
Case "cmdRemoved"
Print pvRemoveDevice(Handle, devicesSelected, chkShowHidden.Checked)
Case "cmdEject"
Print pvEjectDevice(Handle, devicesSelected)
Case "cmdUninstall"
Print pvUninstallDevice(Handle, devicesSelected, chkShowHidden.Checked)
Case "cmdUpdate"
Print pvUpdateDevice(Handle, devicesSelected, chkShowHidden.Checked)
End Select
End If
End Sub