Source code of Windows XP (NT5)
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.

1711 lines
54 KiB

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "comctl32.ocx"
  3. Begin VB.Form MainForm
  4. Caption = "Metabase Editor"
  5. ClientHeight = 7590
  6. ClientLeft = 165
  7. ClientTop = 735
  8. ClientWidth = 10290
  9. Icon = "MetaEdit.frx":0000
  10. LinkTopic = "Form1"
  11. ScaleHeight = 7590
  12. ScaleWidth = 10290
  13. StartUpPosition = 3 'Windows Default
  14. Begin ComctlLib.ListView DataListView
  15. Height = 4575
  16. Left = 3720
  17. TabIndex = 1
  18. Top = 120
  19. Width = 6495
  20. _ExtentX = 11456
  21. _ExtentY = 8070
  22. View = 3
  23. LabelEdit = 1
  24. Sorted = -1 'True
  25. LabelWrap = -1 'True
  26. HideSelection = -1 'True
  27. _Version = 327680
  28. Icons = "DataImageList"
  29. SmallIcons = "DataImageList"
  30. ForeColor = -2147483640
  31. BackColor = -2147483643
  32. Appearance = 1
  33. MouseIcon = "MetaEdit.frx":0442
  34. NumItems = 6
  35. BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  36. Key = "Id"
  37. Object.Tag = ""
  38. Text = "Id"
  39. Object.Width = 176
  40. EndProperty
  41. BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  42. SubItemIndex = 1
  43. Key = "Name"
  44. Object.Tag = ""
  45. Text = "Name"
  46. Object.Width = 176
  47. EndProperty
  48. BeginProperty ColumnHeader(3) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  49. SubItemIndex = 2
  50. Key = "Attributes"
  51. Object.Tag = ""
  52. Text = "Attributes"
  53. Object.Width = 176
  54. EndProperty
  55. BeginProperty ColumnHeader(4) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  56. SubItemIndex = 3
  57. Key = "UserType"
  58. Object.Tag = ""
  59. Text = "UT"
  60. Object.Width = 176
  61. EndProperty
  62. BeginProperty ColumnHeader(5) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  63. SubItemIndex = 4
  64. Key = "DataType"
  65. Object.Tag = ""
  66. Text = "DT"
  67. Object.Width = 176
  68. EndProperty
  69. BeginProperty ColumnHeader(6) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  70. SubItemIndex = 5
  71. Key = "Data"
  72. Object.Tag = ""
  73. Text = "Data"
  74. Object.Width = 176
  75. EndProperty
  76. End
  77. Begin ComctlLib.StatusBar MainStatusBar
  78. Align = 2 'Align Bottom
  79. Height = 375
  80. Left = 0
  81. TabIndex = 2
  82. Top = 7215
  83. Width = 10290
  84. _ExtentX = 18150
  85. _ExtentY = 661
  86. Style = 1
  87. SimpleText = ""
  88. _Version = 327680
  89. BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
  90. NumPanels = 1
  91. BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
  92. TextSave = ""
  93. Key = ""
  94. Object.Tag = ""
  95. EndProperty
  96. EndProperty
  97. MouseIcon = "MetaEdit.frx":045E
  98. End
  99. Begin ComctlLib.TreeView KeyTreeView
  100. Height = 4575
  101. Left = 120
  102. TabIndex = 0
  103. Top = 120
  104. Width = 3495
  105. _ExtentX = 6165
  106. _ExtentY = 8070
  107. _Version = 327680
  108. Indentation = 529
  109. LineStyle = 1
  110. Style = 7
  111. ImageList = "KeyImageList"
  112. Appearance = 1
  113. MouseIcon = "MetaEdit.frx":047A
  114. End
  115. Begin ComctlLib.ListView ErrorListView
  116. Height = 2295
  117. Left = 120
  118. TabIndex = 3
  119. Top = 4800
  120. Visible = 0 'False
  121. Width = 10095
  122. _ExtentX = 17806
  123. _ExtentY = 4048
  124. View = 3
  125. LabelEdit = 1
  126. Sorted = -1 'True
  127. LabelWrap = -1 'True
  128. HideSelection = -1 'True
  129. _Version = 327680
  130. Icons = "ErrorImageList"
  131. SmallIcons = "ErrorImageList"
  132. ForeColor = -2147483640
  133. BackColor = -2147483643
  134. BorderStyle = 1
  135. Appearance = 1
  136. MouseIcon = "MetaEdit.frx":0496
  137. NumItems = 5
  138. BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  139. Key = "Key"
  140. Object.Tag = ""
  141. Text = "Key"
  142. Object.Width = 1764
  143. EndProperty
  144. BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  145. SubItemIndex = 1
  146. Key = "Property"
  147. Object.Tag = ""
  148. Text = "Property"
  149. Object.Width = 882
  150. EndProperty
  151. BeginProperty ColumnHeader(3) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  152. SubItemIndex = 2
  153. Key = "Id"
  154. Object.Tag = ""
  155. Text = "Id"
  156. Object.Width = 882
  157. EndProperty
  158. BeginProperty ColumnHeader(4) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  159. SubItemIndex = 3
  160. Key = "Severity"
  161. Object.Tag = ""
  162. Text = "Severity"
  163. Object.Width = 882
  164. EndProperty
  165. BeginProperty ColumnHeader(5) {0713E8C7-850A-101B-AFC0-4210102A8DA7}
  166. SubItemIndex = 4
  167. Key = "Description"
  168. Object.Tag = ""
  169. Text = "Description"
  170. Object.Width = 2646
  171. EndProperty
  172. End
  173. Begin ComctlLib.ImageList ErrorImageList
  174. Left = 1560
  175. Top = 7200
  176. _ExtentX = 1005
  177. _ExtentY = 1005
  178. BackColor = -2147483643
  179. ImageWidth = 16
  180. ImageHeight = 16
  181. MaskColor = 12632256
  182. _Version = 327680
  183. BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7}
  184. NumListImages = 3
  185. BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
  186. Picture = "MetaEdit.frx":04B2
  187. Key = ""
  188. EndProperty
  189. BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
  190. Picture = "MetaEdit.frx":07CC
  191. Key = ""
  192. EndProperty
  193. BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
  194. Picture = "MetaEdit.frx":0AE6
  195. Key = ""
  196. EndProperty
  197. EndProperty
  198. End
  199. Begin ComctlLib.ImageList DataImageList
  200. Left = 840
  201. Top = 7200
  202. _ExtentX = 1005
  203. _ExtentY = 1005
  204. BackColor = -2147483643
  205. ImageWidth = 16
  206. ImageHeight = 16
  207. MaskColor = 12632256
  208. _Version = 327680
  209. BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7}
  210. NumListImages = 2
  211. BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
  212. Picture = "MetaEdit.frx":0E00
  213. Key = ""
  214. EndProperty
  215. BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
  216. Picture = "MetaEdit.frx":111A
  217. Key = ""
  218. EndProperty
  219. EndProperty
  220. End
  221. Begin ComctlLib.ImageList KeyImageList
  222. Left = 120
  223. Top = 7200
  224. _ExtentX = 1005
  225. _ExtentY = 1005
  226. BackColor = -2147483643
  227. ImageWidth = 16
  228. ImageHeight = 16
  229. MaskColor = 12632256
  230. UseMaskColor = 0 'False
  231. _Version = 327680
  232. BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7}
  233. NumListImages = 5
  234. BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
  235. Picture = "MetaEdit.frx":1434
  236. Key = ""
  237. EndProperty
  238. BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
  239. Picture = "MetaEdit.frx":174E
  240. Key = ""
  241. EndProperty
  242. BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
  243. Picture = "MetaEdit.frx":1A68
  244. Key = ""
  245. EndProperty
  246. BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
  247. Picture = "MetaEdit.frx":1D82
  248. Key = ""
  249. EndProperty
  250. BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
  251. Picture = "MetaEdit.frx":209C
  252. Key = ""
  253. EndProperty
  254. EndProperty
  255. End
  256. Begin VB.Menu MetabaseMenu
  257. Caption = "&Metabase"
  258. Begin VB.Menu BackupMenuItem
  259. Caption = "&Backup"
  260. Visible = 0 'False
  261. End
  262. Begin VB.Menu RestoreMenuItem
  263. Caption = "&Restore"
  264. Visible = 0 'False
  265. End
  266. Begin VB.Menu Seperator11
  267. Caption = "-"
  268. Visible = 0 'False
  269. End
  270. Begin VB.Menu ExitMenuItem
  271. Caption = "E&xit"
  272. End
  273. End
  274. Begin VB.Menu EditMenu
  275. Caption = "&Edit"
  276. Begin VB.Menu NewMenu
  277. Caption = "&New"
  278. Begin VB.Menu NewKeyMenuItem
  279. Caption = "&Key"
  280. End
  281. Begin VB.Menu Seperator211
  282. Caption = "-"
  283. End
  284. Begin VB.Menu NewDwordMenuItem
  285. Caption = "&DWORD"
  286. End
  287. Begin VB.Menu NewStringMenuItem
  288. Caption = "&String"
  289. End
  290. Begin VB.Menu NewBinaryMenuItem
  291. Caption = "&Binary"
  292. End
  293. Begin VB.Menu NewExpandStringMenuItem
  294. Caption = "&Expand String"
  295. End
  296. Begin VB.Menu NewMultiStringMenuItem
  297. Caption = "&Multi-String"
  298. End
  299. End
  300. Begin VB.Menu DeleteMenuItem
  301. Caption = "&Delete"
  302. Shortcut = {DEL}
  303. End
  304. Begin VB.Menu Seperator21
  305. Caption = "-"
  306. End
  307. Begin VB.Menu RenameKeyMenuItem
  308. Caption = "&Rename Key"
  309. End
  310. Begin VB.Menu CopyKeyMenuItem
  311. Caption = "&Copy Key"
  312. End
  313. End
  314. Begin VB.Menu SearchMenu
  315. Caption = "&Search"
  316. Begin VB.Menu FindMenuItem
  317. Caption = "&Find"
  318. Shortcut = ^F
  319. End
  320. Begin VB.Menu FindNextMenuItem
  321. Caption = "Find &Next"
  322. Shortcut = {F3}
  323. End
  324. End
  325. Begin VB.Menu CheckMenu
  326. Caption = "&Check"
  327. Begin VB.Menu CheckSchemaMenuItem
  328. Caption = "&Schema"
  329. End
  330. Begin VB.Menu CheckKeyMenuItem
  331. Caption = "&Key"
  332. End
  333. Begin VB.Menu CheckAllMenuItem
  334. Caption = "&All Keys"
  335. End
  336. Begin VB.Menu Seperator31
  337. Caption = "-"
  338. End
  339. Begin VB.Menu CheckOptionsMenuItem
  340. Caption = "&Options"
  341. End
  342. End
  343. Begin VB.Menu ViewMenu
  344. Caption = "&View"
  345. Begin VB.Menu ErrorListMenuItem
  346. Caption = "&Error List"
  347. Checked = -1 'True
  348. End
  349. Begin VB.Menu StatusBarMenuItem
  350. Caption = "&Status Bar"
  351. Checked = -1 'True
  352. End
  353. Begin VB.Menu Seprerator41
  354. Caption = "-"
  355. End
  356. Begin VB.Menu RefreshMenuItem
  357. Caption = "&Refresh"
  358. Shortcut = {F5}
  359. End
  360. End
  361. Begin VB.Menu HelpMenu
  362. Caption = "&Help"
  363. Begin VB.Menu AboutMenuItem
  364. Caption = "&About Metabase Editor"
  365. End
  366. End
  367. Begin VB.Menu KeyMenu
  368. Caption = "KeyMenu"
  369. Visible = 0 'False
  370. Begin VB.Menu ExpandKeyMenuItem
  371. Caption = "&Expand"
  372. End
  373. Begin VB.Menu Seperator61
  374. Caption = "-"
  375. End
  376. Begin VB.Menu KeyNewMenuItem
  377. Caption = "&New"
  378. Begin VB.Menu KeyNewKeyMenuItem
  379. Caption = "&Key"
  380. End
  381. Begin VB.Menu Seperator611
  382. Caption = "-"
  383. End
  384. Begin VB.Menu KeyNewDwordMenuItem
  385. Caption = "&DWORD"
  386. End
  387. Begin VB.Menu KeyNewStringMenuItem
  388. Caption = "&String"
  389. End
  390. Begin VB.Menu KeyNewBinaryMenuItem
  391. Caption = "&Binary"
  392. End
  393. Begin VB.Menu KeyNewExpandSzMenuItem
  394. Caption = "&Expand String"
  395. End
  396. Begin VB.Menu KeyNewMultiSzMenuItem
  397. Caption = "&Multi-String"
  398. End
  399. End
  400. Begin VB.Menu KeyDeleteMenuItem
  401. Caption = "&Delete"
  402. End
  403. Begin VB.Menu KeyRenameMenuItem
  404. Caption = "&Rename"
  405. End
  406. Begin VB.Menu KeyCopyMenuItem
  407. Caption = "&Copy"
  408. End
  409. Begin VB.Menu Seperator62
  410. Caption = "-"
  411. End
  412. Begin VB.Menu KeyCheckMenuItem
  413. Caption = "&Check"
  414. End
  415. End
  416. Begin VB.Menu DataMenu
  417. Caption = "DataMenu"
  418. Visible = 0 'False
  419. Begin VB.Menu DataModifyMenuItem
  420. Caption = "&Modify"
  421. End
  422. Begin VB.Menu Seperator71
  423. Caption = "-"
  424. End
  425. Begin VB.Menu DataNewMenu
  426. Caption = "&New"
  427. Begin VB.Menu DataNewDwordMenuItem
  428. Caption = "&DWORD"
  429. End
  430. Begin VB.Menu DataNewStringMenuItem
  431. Caption = "&String"
  432. End
  433. Begin VB.Menu DataNewBinaryMenuItem
  434. Caption = "&Binary"
  435. End
  436. Begin VB.Menu DataNewExpandSzMenuItem
  437. Caption = "&ExpandString"
  438. End
  439. Begin VB.Menu DataNewMultiSzMenuItem
  440. Caption = "&Multi-String"
  441. End
  442. End
  443. Begin VB.Menu DataDeleteMenuItem
  444. Caption = "&Delete"
  445. End
  446. End
  447. End
  448. Attribute VB_Name = "MainForm"
  449. Attribute VB_GlobalNameSpace = False
  450. Attribute VB_Creatable = False
  451. Attribute VB_PredeclaredId = True
  452. Attribute VB_Exposed = False
  453. Option Explicit
  454. DefInt A-Z
  455. 'Globals
  456. 'Metabase globals
  457. Public MetaUtilObj As Object
  458. Const METADATA_NO_ATTRIBUTES = &H0
  459. Const METADATA_INHERIT = &H1
  460. Const METADATA_PARTIAL_PATH = &H2
  461. Const METADATA_SECURE = &H4
  462. Const METADATA_REFERENCE = &H8
  463. Const METADATA_VOLATILE = &H10
  464. Const METADATA_ISINHERITED = &H20
  465. Const METADATA_INSERT_PATH = &H40
  466. Const IIS_MD_UT_SERVER = 1
  467. Const IIS_MD_UT_FILE = 2
  468. Const IIS_MD_UT_WAM = 100
  469. Const ASP_MD_UT_APP = 101
  470. Const ALL_METADATA = 0
  471. Const DWORD_METADATA = 1
  472. Const STRING_METADATA = 2
  473. Const BINARY_METADATA = 3
  474. Const EXPANDSZ_METADATA = 4
  475. Const MULTISZ_METADATA = 5
  476. 'Layout globals
  477. Const FormBoarder = 40
  478. Dim VDividerPos As Long 'Start of divider
  479. Dim HDividerPos As Long 'Top relative to the status bar
  480. Dim VDividerHeld As Boolean
  481. Dim HDividerHeld As Boolean
  482. 'State globals
  483. Dim AppCursor As Long
  484. Dim KeyLabelEditOrigText As String
  485. Dim KeyLabelEditOrigFullPath As String
  486. Private Sub Form_Load()
  487. AppCursor = vbDefault
  488. VDividerHeld = False
  489. HDividerHeld = False
  490. 'Load Config
  491. Config.LoadConfig
  492. 'Setup the form
  493. VDividerPos = Config.MainFormVDivider
  494. HDividerPos = Config.MainFormHDivider
  495. MainForm.Height = Config.MainFormHeight
  496. MainForm.Width = Config.MainFormWidth
  497. If Config.StatusBar Then
  498. MainStatusBar.Visible = True
  499. StatusBarMenuItem.Checked = True
  500. Else
  501. MainStatusBar.Visible = False
  502. StatusBarMenuItem.Checked = False
  503. End If
  504. ErrorListMenuItem.Checked = False
  505. ErrorListView.Visible = False
  506. LayoutForm
  507. DataListView.ColumnHeaders(1).Width = Config.DataListIdColWidth
  508. DataListView.ColumnHeaders(2).Width = Config.DataListNameColWidth
  509. DataListView.ColumnHeaders(3).Width = Config.DataListAttrColWidth
  510. DataListView.ColumnHeaders(4).Width = Config.DataListUTColWidth
  511. DataListView.ColumnHeaders(5).Width = Config.DataListDTColWidth
  512. DataListView.ColumnHeaders(6).Width = Config.DataListDataColWidth
  513. ErrorListView.ColumnHeaders(1).Width = Config.ErrorListKeyColWidth
  514. ErrorListView.ColumnHeaders(2).Width = Config.ErrorListPropColWidth
  515. ErrorListView.ColumnHeaders(3).Width = Config.ErrorListIdColWidth
  516. ErrorListView.ColumnHeaders(4).Width = Config.ErrorListSeverityColWidth
  517. ErrorListView.ColumnHeaders(5).Width = Config.ErrorListDescColWidth
  518. 'MsgBox "You may now attach your debugger."
  519. 'Set the data
  520. Set MetaUtilObj = CreateObject("MSWC.MetaUtil")
  521. LoadKeys
  522. ShowSelectedNode
  523. End Sub
  524. Private Sub Form_Unload(Cancel As Integer)
  525. If MainForm.WindowState = vbNormal Then
  526. Config.MainFormHeight = MainForm.Height
  527. Config.MainFormWidth = MainForm.Width
  528. End If
  529. Config.MainFormVDivider = VDividerPos
  530. Config.MainFormHDivider = HDividerPos
  531. Config.DataListIdColWidth = DataListView.ColumnHeaders(1).Width
  532. Config.DataListNameColWidth = DataListView.ColumnHeaders(2).Width
  533. Config.DataListAttrColWidth = DataListView.ColumnHeaders(3).Width
  534. Config.DataListUTColWidth = DataListView.ColumnHeaders(4).Width
  535. Config.DataListDTColWidth = DataListView.ColumnHeaders(5).Width
  536. Config.DataListDataColWidth = DataListView.ColumnHeaders(6).Width
  537. Config.ErrorListKeyColWidth = ErrorListView.ColumnHeaders(1).Width
  538. Config.ErrorListPropColWidth = ErrorListView.ColumnHeaders(2).Width
  539. Config.ErrorListIdColWidth = ErrorListView.ColumnHeaders(3).Width
  540. Config.ErrorListSeverityColWidth = ErrorListView.ColumnHeaders(4).Width
  541. Config.ErrorListDescColWidth = ErrorListView.ColumnHeaders(5).Width
  542. Config.SaveConfig
  543. End Sub
  544. Private Sub Form_Resize()
  545. LayoutForm
  546. End Sub
  547. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  548. If (x > VDividerPos) And _
  549. (x < VDividerPos + FormBoarder) And _
  550. (y <= KeyTreeView.Top + KeyTreeView.Height) Then
  551. VDividerHeld = True
  552. ElseIf ErrorListView.Visible And _
  553. (y > KeyTreeView.Top + KeyTreeView.Height) And _
  554. (y < ErrorListView.Top) Then
  555. HDividerHeld = True
  556. End If
  557. End Sub
  558. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  559. If (x > VDividerPos) And _
  560. (x < VDividerPos + FormBoarder) And _
  561. (y <= KeyTreeView.Top + KeyTreeView.Height) Then
  562. 'Show that the divider can be moved
  563. MainForm.MousePointer = vbSizeWE
  564. ElseIf ErrorListView.Visible And _
  565. (y > KeyTreeView.Top + KeyTreeView.Height) And _
  566. (y < ErrorListView.Top) Then
  567. 'Show that the divider can be moved
  568. MainForm.MousePointer = vbSizeNS
  569. ElseIf Not (VDividerHeld Or HDividerHeld) Then
  570. 'Revert to normal
  571. MainForm.MousePointer = AppCursor
  572. End If
  573. If VDividerHeld Then
  574. 'Move the divider, centering on the cursor
  575. VDividerPos = x - (FormBoarder / 2)
  576. LayoutForm
  577. ElseIf HDividerHeld Then
  578. 'Move the divider, centering on the cursor
  579. If MainStatusBar.Visible Then
  580. HDividerPos = MainStatusBar.Top - y - FormBoarder - (FormBoarder / 2)
  581. Else
  582. HDividerPos = MainForm.ScaleHeight - y - FormBoarder - (FormBoarder / 2)
  583. End If
  584. LayoutForm
  585. End If
  586. End Sub
  587. Private Sub KeyTreeView_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  588. If Not (VDividerHeld Or HDividerHeld) Then
  589. 'Revert to normal
  590. MainForm.MousePointer = AppCursor
  591. End If
  592. End Sub
  593. Private Sub DataListView_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  594. If Not (VDividerHeld Or HDividerHeld) Then
  595. 'Revert to normal
  596. MainForm.MousePointer = AppCursor
  597. End If
  598. End Sub
  599. Private Sub ErrorListView_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  600. If Not (VDividerHeld Or HDividerHeld) Then
  601. 'Revert to normal
  602. MainForm.MousePointer = AppCursor
  603. End If
  604. End Sub
  605. Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  606. If VDividerHeld Then
  607. 'Move the divider, centering on the cursor
  608. VDividerPos = x - (FormBoarder / 2)
  609. LayoutForm
  610. VDividerHeld = False
  611. ElseIf HDividerHeld Then
  612. 'Move the divider, centering on the cursor
  613. If MainStatusBar.Visible Then
  614. HDividerPos = MainStatusBar.Top - y - FormBoarder - (FormBoarder / 2)
  615. Else
  616. HDividerPos = MainForm.ScaleHeight - y - FormBoarder - (FormBoarder / 2)
  617. End If
  618. LayoutForm
  619. HDividerHeld = False
  620. End If
  621. End Sub
  622. Private Sub LayoutForm()
  623. If MainForm.WindowState <> vbMinimized Then
  624. 'Enforce divider ranges
  625. If VDividerPos < 2 * FormBoarder Then
  626. VDividerPos = 2 * FormBoarder
  627. ElseIf VDividerPos > MainForm.ScaleWidth - (FormBoarder * 2) Then
  628. VDividerPos = MainForm.ScaleWidth - (FormBoarder * 2)
  629. End If
  630. If HDividerPos < FormBoarder Then
  631. HDividerPos = FormBoarder
  632. ElseIf HDividerPos > MainForm.ScaleHeight - MainStatusBar.Height - (FormBoarder * 3) Then
  633. HDividerPos = MainForm.ScaleHeight - MainStatusBar.Height - (FormBoarder * 3)
  634. End If
  635. 'Enforce a minimum size
  636. If MainForm.ScaleWidth < FormBoarder * 3 + VDividerPos Then
  637. MainForm.Width = (MainForm.Width - MainForm.ScaleWidth) + FormBoarder * 3 + VDividerPos
  638. Exit Sub
  639. End If
  640. If MainStatusBar.Visible And ErrorListView.Visible Then
  641. If MainForm.ScaleHeight < MainStatusBar.Height + HDividerPos + (FormBoarder * 4) Then
  642. MainForm.Height = (MainForm.Height - MainForm.ScaleHeight) + MainStatusBar.Height + HDividerPos + (FormBoarder * 4)
  643. Exit Sub
  644. End If
  645. ElseIf MainStatusBar.Visible Then
  646. If MainForm.ScaleHeight < MainStatusBar.Height + (FormBoarder * 3) Then
  647. MainForm.Height = (MainForm.Height - MainForm.ScaleHeight) + MainStatusBar.Height + (FormBoarder * 3)
  648. Exit Sub
  649. End If
  650. ElseIf ErrorListView.Visible Then
  651. If MainForm.ScaleHeight < HDividerPos + (FormBoarder * 3) Then
  652. MainForm.Height = (MainForm.Height - MainForm.ScaleHeight) + HDividerPos + (FormBoarder * 3)
  653. Exit Sub
  654. End If
  655. Else
  656. If MainForm.ScaleHeight < (FormBoarder * 3) Then
  657. MainForm.ScaleHeight = (MainForm.Height - MainForm.ScaleHeight) + (FormBoarder * 3)
  658. Exit Sub
  659. End If
  660. End If
  661. 'KeyTreeView
  662. KeyTreeView.Left = FormBoarder
  663. KeyTreeView.Top = FormBoarder
  664. KeyTreeView.Width = VDividerPos - FormBoarder
  665. If MainStatusBar.Visible And ErrorListView.Visible Then
  666. KeyTreeView.Height = MainForm.ScaleHeight - HDividerPos - MainStatusBar.Height - (3 * FormBoarder)
  667. ElseIf MainStatusBar.Visible Then
  668. KeyTreeView.Height = MainForm.ScaleHeight - MainStatusBar.Height - (2 * FormBoarder)
  669. ElseIf ErrorListView.Visible Then
  670. KeyTreeView.Height = MainForm.ScaleHeight - HDividerPos - (3 * FormBoarder)
  671. Else
  672. KeyTreeView.Height = MainForm.ScaleHeight - (2 * FormBoarder)
  673. End If
  674. 'DataListView
  675. DataListView.Left = VDividerPos + FormBoarder
  676. DataListView.Top = FormBoarder
  677. DataListView.Width = MainForm.ScaleWidth - VDividerPos - (2 * FormBoarder)
  678. If MainStatusBar.Visible And ErrorListView.Visible Then
  679. DataListView.Height = MainForm.ScaleHeight - HDividerPos - MainStatusBar.Height - (3 * FormBoarder)
  680. ElseIf MainStatusBar.Visible Then
  681. DataListView.Height = MainForm.ScaleHeight - MainStatusBar.Height - (2 * FormBoarder)
  682. ElseIf ErrorListView.Visible Then
  683. DataListView.Height = MainForm.ScaleHeight - HDividerPos - (3 * FormBoarder)
  684. Else
  685. DataListView.Height = MainForm.ScaleHeight - (2 * FormBoarder)
  686. End If
  687. 'ErrorListView
  688. If ErrorListView.Visible Then
  689. ErrorListView.Left = FormBoarder
  690. ErrorListView.Width = MainForm.ScaleWidth - (2 * FormBoarder)
  691. ErrorListView.Top = KeyTreeView.Top + KeyTreeView.Height + FormBoarder
  692. ErrorListView.Height = HDividerPos
  693. End If
  694. End If
  695. End Sub
  696. Private Sub KeyTreeView_Expand(ByVal CurNode As ComctlLib.Node)
  697. 'Look for grandchildren
  698. If (CurNode.Tag) And (CurNode.Children > 0) Then
  699. Dim SubNode As Node
  700. Dim SubKeyStr As Variant
  701. Dim NewNode As Node
  702. 'For Each sub-node
  703. Set SubNode = CurNode.Child
  704. Do
  705. For Each SubKeyStr In MetaUtilObj.EnumKeys(SubNode.FullPath)
  706. Set NewNode = KeyTreeView.Nodes.Add(SubNode, tvwChild, SubNode.FullPath & "/" & SubKeyStr, SubKeyStr)
  707. NewNode.Key = NewNode.FullPath
  708. NewNode.Image = 1
  709. NewNode.ExpandedImage = 2
  710. 'Set node as unvisited
  711. NewNode.Tag = True
  712. Next
  713. 'Resort
  714. SubNode.Sorted = True
  715. 'Next sub-node or bail
  716. If SubNode Is SubNode.LastSibling Then Exit Do
  717. Set SubNode = SubNode.Next
  718. Loop
  719. 'Set node as visited
  720. CurNode.Tag = False
  721. End If
  722. End Sub
  723. Private Sub KeyTreeView_Collapse(ByVal Node As ComctlLib.Node)
  724. ShowSelectedNode
  725. End Sub
  726. Private Sub KeyTreeView_KeyPress(KeyAscii As Integer)
  727. ShowSelectedNode
  728. End Sub
  729. Private Sub KeyTreeView_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  730. If Button = vbRightButton Then
  731. PopupMenu KeyMenu, , , , ExpandKeyMenuItem
  732. End If
  733. End Sub
  734. Private Sub KeyTreeView_NodeClick(ByVal Node As ComctlLib.Node)
  735. ShowSelectedNode
  736. End Sub
  737. Private Sub KeyTreeView_BeforeLabelEdit(Cancel As Integer)
  738. If KeyTreeView.SelectedItem Is Nothing Then
  739. 'Cancel
  740. Cancel = 1
  741. Else
  742. KeyLabelEditOrigText = KeyTreeView.SelectedItem.Text
  743. KeyLabelEditOrigFullPath = KeyTreeView.SelectedItem.FullPath
  744. End If
  745. End Sub
  746. Private Sub KeyTreeView_AfterLabelEdit(Cancel As Integer, NewString As String)
  747. On Error GoTo LError
  748. Dim NewFullPath As String
  749. If (KeyTreeView.SelectedItem Is Nothing) Or (NewString = "") Then
  750. Cancel = 1
  751. ElseIf KeyLabelEditOrigText <> "" Then
  752. 'Figure out the new full path
  753. If KeyTreeView.SelectedItem.Root Is KeyTreeView.SelectedItem Then
  754. NewFullPath = NewString
  755. Else
  756. NewFullPath = KeyTreeView.SelectedItem.Parent.FullPath & "\" & NewString
  757. End If
  758. If NewString <> KeyLabelEditOrigText Then
  759. 'Rename key
  760. KeyTreeView.SelectedItem.Key = NewFullPath
  761. MetaUtilObj.RenameKey KeyLabelEditOrigFullPath, NewFullPath
  762. KeyTreeView.SelectedItem.Text = NewString
  763. End If
  764. End If
  765. Exit Sub
  766. LError:
  767. KeyTreeView.SelectedItem.Text = KeyLabelEditOrigText
  768. KeyTreeView.SelectedItem.Key = KeyLabelEditOrigFullPath
  769. MsgBox "Failure to rename key: " & Err.Description, vbExclamation + vbOKOnly, "Rename Key"
  770. Cancel = 1
  771. End Sub
  772. Private Sub LoadKeys()
  773. 'Clear selected node
  774. DataListView.Tag = ""
  775. 'Initialize the tree
  776. Dim KeyStr As Variant
  777. Dim NewNode As Node
  778. Dim SubKeyStr As Variant
  779. Dim NewSubNode As Node
  780. For Each KeyStr In MetaUtilObj.EnumKeys("")
  781. Set NewNode = KeyTreeView.Nodes.Add(, , KeyStr, KeyStr)
  782. NewNode.Key = NewNode.FullPath
  783. NewNode.Image = 3
  784. 'Set node as unvisited
  785. NewNode.Tag = True
  786. For Each SubKeyStr In MetaUtilObj.EnumKeys(KeyStr)
  787. Set NewSubNode = KeyTreeView.Nodes.Add(NewNode, tvwChild, KeyStr & "/" & SubKeyStr, SubKeyStr)
  788. NewSubNode.Key = NewSubNode.FullPath
  789. NewSubNode.Image = 1
  790. NewSubNode.ExpandedImage = 2
  791. 'Set node as unvisited
  792. NewSubNode.Tag = True
  793. Next
  794. 'Resort
  795. NewNode.Sorted = True
  796. Next
  797. 'Resort
  798. KeyTreeView.Sorted = True
  799. Set KeyTreeView.SelectedItem = KeyTreeView.Nodes.Item(1)
  800. End Sub
  801. Public Sub SelectKey(Key As String)
  802. Dim ParentKey As String
  803. Dim ChildKey As String
  804. Dim CurKey As String
  805. ParentKey = Key
  806. ChildKey = ""
  807. Do While ParentKey <> ""
  808. 'Get the current key
  809. CurKey = ""
  810. Do While (ParentKey <> "") And _
  811. (Left(ParentKey, 1) <> "\") And _
  812. (Left(ParentKey, 1) <> "/")
  813. CurKey = CurKey & Left(ParentKey, 1)
  814. ParentKey = Right(ParentKey, Len(ParentKey) - 1)
  815. Loop
  816. If (ParentKey <> "") Then
  817. 'Skip the slash
  818. ParentKey = Right(ParentKey, Len(ParentKey) - 1)
  819. End If
  820. If ChildKey = "" Then
  821. ChildKey = CurKey
  822. Else
  823. ChildKey = ChildKey & "\" & CurKey
  824. End If
  825. If ParentKey <> "" Then
  826. KeyTreeView.Nodes(ChildKey).Expanded = True
  827. End If
  828. Loop
  829. Set KeyTreeView.SelectedItem = KeyTreeView.Nodes(ChildKey)
  830. KeyTreeView.Nodes(ChildKey).EnsureVisible
  831. ShowSelectedNode
  832. KeyTreeView.SetFocus
  833. End Sub
  834. Private Sub RefreshKeys()
  835. Dim SelectedKey As String
  836. 'Save the selected key
  837. If KeyTreeView.SelectedItem Is Nothing Then
  838. SelectedKey = ""
  839. Else
  840. SelectedKey = KeyTreeView.SelectedItem.FullPath
  841. End If
  842. 'Reload
  843. KeyTreeView.Nodes.Clear
  844. LoadKeys
  845. 'Restore the selected key
  846. If SelectedKey <> "" Then
  847. SelectKey SelectedKey
  848. End If
  849. End Sub
  850. Private Sub DataListView_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  851. If Button = vbRightButton Then
  852. PopupMenu DataMenu, , , , DataModifyMenuItem
  853. End If
  854. End Sub
  855. Private Sub DataListView_DblClick()
  856. If Not DataListView.SelectedItem Is Nothing Then
  857. 'Edit the selected data item
  858. If DataListView.SelectedItem.SubItems(4) = "DWord" Or _
  859. DataListView.SelectedItem.SubItems(4) = "String" Or _
  860. DataListView.SelectedItem.SubItems(4) = "ExpandSz" Or _
  861. DataListView.SelectedItem.SubItems(4) = "Binary" Then
  862. 'Set the form parameters
  863. SimpleEditForm.Machine = KeyTreeView.SelectedItem.Root.FullPath
  864. SimpleEditForm.Key = KeyTreeView.SelectedItem.FullPath
  865. SimpleEditForm.Id = CLng(DataListView.SelectedItem.Text)
  866. 'Run it
  867. SimpleEditForm.Init
  868. SimpleEditForm.Show vbModal, Me
  869. ElseIf DataListView.SelectedItem.SubItems(4) = "MultiSz" Then
  870. 'Set the form parameters
  871. MultiEditForm.Machine = KeyTreeView.SelectedItem.Root.FullPath
  872. MultiEditForm.Key = KeyTreeView.SelectedItem.FullPath
  873. MultiEditForm.Id = CLng(DataListView.SelectedItem.Text)
  874. 'Run it
  875. MultiEditForm.Init
  876. MultiEditForm.Show vbModal, Me
  877. End If
  878. 'Refresh DataListView
  879. RefreshData
  880. End If
  881. End Sub
  882. Private Sub DataListView_ColumnClick(ByVal ColumnHeader As ComctlLib.ColumnHeader)
  883. If DataListView.SortKey = ColumnHeader.Index - 1 Then
  884. 'Reverse the sort order
  885. If DataListView.SortOrder = lvwAscending Then
  886. DataListView.SortOrder = lvwDescending
  887. Else
  888. DataListView.SortOrder = lvwAscending
  889. End If
  890. Else
  891. 'Sort ascending on this column
  892. DataListView.SortOrder = lvwAscending
  893. DataListView.SortKey = ColumnHeader.Index - 1
  894. End If
  895. ' Resort
  896. DataListView.Sorted = True
  897. End Sub
  898. Private Sub ShowSelectedNode()
  899. Dim SelNode As Node
  900. Set SelNode = KeyTreeView.SelectedItem
  901. If SelNode Is Nothing Then
  902. DataListView.ListItems.Clear
  903. ElseIf SelNode.FullPath <> DataListView.Tag Then
  904. 'Update the status bar
  905. MainStatusBar.SimpleText = SelNode.FullPath
  906. 'Update the DataListView
  907. DataListView.Tag = SelNode.FullPath
  908. DataListView.ListItems.Clear
  909. 'Property values are copied for efficency (less calls into Property)
  910. Dim Property As Variant
  911. Dim NewItem As ListItem
  912. Dim Id As Long
  913. Dim Attributes As Long
  914. Dim AttrStr As String
  915. Dim UserType As Long
  916. Dim DataType As Long
  917. Dim Data As Variant
  918. Dim DataStr As String
  919. Dim DataBStr As String
  920. Dim i As Integer
  921. Dim DataByte As Integer
  922. For Each Property In MetaUtilObj.EnumProperties(SelNode.FullPath)
  923. Set NewItem = DataListView.ListItems.Add()
  924. 'Id (padded with spaces so it sorts)
  925. Id = Property.Id
  926. NewItem.Text = String(10 - Len(Str(Id)), " ") + Str(Id)
  927. 'Name
  928. NewItem.SubItems(1) = Property.Name
  929. 'Attributes
  930. Attributes = Property.Attributes
  931. AttrStr = ""
  932. If (Attributes And METADATA_INHERIT) = METADATA_INHERIT Then
  933. If AttrStr <> "" Then AttrStr = AttrStr & " "
  934. AttrStr = AttrStr & "Inh"
  935. End If
  936. If (Attributes And METADATA_PARTIAL_PATH) = METADATA_PARTIAL_PATH Then
  937. If AttrStr <> "" Then AttrStr = AttrStr & " "
  938. AttrStr = AttrStr & "Pp"
  939. End If
  940. If (Attributes And METADATA_SECURE) = METADATA_SECURE Then
  941. If AttrStr <> "" Then AttrStr = AttrStr & " "
  942. AttrStr = AttrStr & "Sec"
  943. End If
  944. If (Attributes And METADATA_REFERENCE) = METADATA_REFERENCE Then
  945. If AttrStr <> "" Then AttrStr = AttrStr & " "
  946. AttrStr = AttrStr & "Ref"
  947. End If
  948. If (Attributes And METADATA_VOLATILE) = METADATA_VOLATILE Then
  949. If AttrStr <> "" Then AttrStr = AttrStr & " "
  950. AttrStr = AttrStr & "Vol"
  951. End If
  952. If (Attributes And METADATA_ISINHERITED) = METADATA_ISINHERITED Then
  953. If AttrStr <> "" Then AttrStr = AttrStr & " "
  954. AttrStr = AttrStr & "IsInh"
  955. End If
  956. If (Attributes And METADATA_INSERT_PATH) = METADATA_INSERT_PATH Then
  957. If AttrStr <> "" Then AttrStr = AttrStr & " "
  958. AttrStr = AttrStr & "Ins"
  959. End If
  960. NewItem.SubItems(2) = AttrStr
  961. 'User Type
  962. UserType = Property.UserType
  963. If UserType = IIS_MD_UT_SERVER Then
  964. NewItem.SubItems(3) = "Server"
  965. ElseIf UserType = IIS_MD_UT_FILE Then
  966. NewItem.SubItems(3) = "File"
  967. ElseIf UserType = IIS_MD_UT_WAM Then
  968. NewItem.SubItems(3) = "WAM"
  969. ElseIf UserType = ASP_MD_UT_APP Then
  970. NewItem.SubItems(3) = "ASP App"
  971. Else
  972. NewItem.SubItems(3) = Str(UserType)
  973. End If
  974. 'Data Type
  975. DataType = Property.DataType
  976. If DataType = ALL_METADATA Then
  977. NewItem.SubItems(4) = "*All*"
  978. ElseIf DataType = DWORD_METADATA Then
  979. NewItem.SubItems(4) = "DWord"
  980. ElseIf DataType = STRING_METADATA Then
  981. NewItem.SubItems(4) = "String"
  982. ElseIf DataType = BINARY_METADATA Then
  983. NewItem.SubItems(4) = "Binary"
  984. ElseIf DataType = EXPANDSZ_METADATA Then
  985. NewItem.SubItems(4) = "ExpandSz"
  986. ElseIf DataType = MULTISZ_METADATA Then
  987. NewItem.SubItems(4) = "MultiSz"
  988. Else
  989. NewItem.SubItems(4) = "*Unknown*"
  990. End If
  991. 'Data
  992. Data = Property.Data
  993. If (Attributes And METADATA_SECURE) = METADATA_SECURE Then
  994. DataStr = "*Not Displayed*"
  995. ElseIf DataType = BINARY_METADATA Then
  996. 'Display as a list of bytes
  997. DataStr = ""
  998. DataBStr = Property.Data
  999. For i = 1 To LenB(DataBStr)
  1000. DataByte = AscB(MidB(DataBStr, i, 1))
  1001. If DataByte < 16 Then
  1002. DataStr = DataStr & "0" & Hex(AscB(MidB(DataBStr, i, 1))) & " "
  1003. Else
  1004. DataStr = DataStr & Hex(AscB(MidB(DataBStr, i, 1))) & " "
  1005. End If
  1006. Next
  1007. ElseIf DataType = MULTISZ_METADATA Then
  1008. 'Display as a list of strings
  1009. If IsArray(Data) Then
  1010. DataStr = ""
  1011. For i = LBound(Data) To UBound(Data)
  1012. If i = LBound(Data) Then
  1013. DataStr = CStr(Data(i))
  1014. Else
  1015. DataStr = DataStr & " " & CStr(Data(i))
  1016. End If
  1017. Next
  1018. End If
  1019. Else
  1020. DataStr = CStr(Data)
  1021. End If
  1022. NewItem.SubItems(5) = DataStr
  1023. 'Set the icon
  1024. If (DataType = STRING_METADATA) Or _
  1025. (DataType = EXPANDSZ_METADATA) Or _
  1026. (DataType = MULTISZ_METADATA) Then
  1027. NewItem.SmallIcon = 1
  1028. Else
  1029. NewItem.SmallIcon = 2
  1030. End If
  1031. Next
  1032. End If
  1033. End Sub
  1034. Public Sub SelectProperty(PropertyStr As String)
  1035. 'Had to search since I couldn't get the key property working
  1036. Dim i As Long
  1037. i = 1
  1038. Do While (i <= DataListView.ListItems.Count) And (PropertyStr <> DataListView.ListItems(i))
  1039. i = i + 1
  1040. Loop
  1041. If PropertyStr = DataListView.ListItems(i) Then
  1042. 'Found it
  1043. Set DataListView.SelectedItem = DataListView.ListItems(i)
  1044. DataListView.ListItems(i).EnsureVisible
  1045. DataListView.SetFocus
  1046. End If
  1047. End Sub
  1048. Private Sub RefreshData()
  1049. Dim SelectedProperty As String
  1050. 'Save the selected property
  1051. If DataListView.SelectedItem Is Nothing Then
  1052. SelectedProperty = ""
  1053. Else
  1054. SelectedProperty = DataListView.SelectedItem.Text
  1055. End If
  1056. 'Reload
  1057. DataListView.Tag = ""
  1058. ShowSelectedNode
  1059. 'Restore the selected property
  1060. If SelectedProperty <> "" Then
  1061. SelectProperty SelectedProperty
  1062. End If
  1063. End Sub
  1064. Private Sub ErrorListView_ColumnClick(ByVal ColumnHeader As ComctlLib.ColumnHeader)
  1065. If ErrorListView.SortKey = ColumnHeader.Index - 1 Then
  1066. 'Reverse the sort order
  1067. If ErrorListView.SortOrder = lvwAscending Then
  1068. ErrorListView.SortOrder = lvwDescending
  1069. Else
  1070. ErrorListView.SortOrder = lvwAscending
  1071. End If
  1072. Else
  1073. 'Sort ascending on this column
  1074. ErrorListView.SortOrder = lvwAscending
  1075. ErrorListView.SortKey = ColumnHeader.Index - 1
  1076. End If
  1077. ' Resort
  1078. ErrorListView.Sorted = True
  1079. End Sub
  1080. Private Sub ErrorListView_DblClick()
  1081. If Not ErrorListView.SelectedItem Is Nothing Then
  1082. SelectKey ErrorListView.SelectedItem.Text
  1083. If ErrorListView.SelectedItem.SubItems(1) <> " 0" Then
  1084. SelectProperty ErrorListView.SelectedItem.SubItems(1)
  1085. End If
  1086. End If
  1087. End Sub
  1088. Private Sub AddErrorToErrorListView(CheckError As Variant)
  1089. Dim NewItem As ListItem
  1090. Dim Key As String
  1091. Dim Property As Long
  1092. Dim Id As Long
  1093. Dim Severity As Long
  1094. Dim Description As String
  1095. Key = CheckError.Key
  1096. Property = CheckError.Property
  1097. Id = CheckError.Id
  1098. Severity = CheckError.Severity
  1099. Description = CheckError.Description
  1100. Set NewItem = ErrorListView.ListItems.Add
  1101. NewItem.Text = Key
  1102. NewItem.SubItems(1) = String(10 - Len(Str(Property)), " ") + Str(Property)
  1103. NewItem.SubItems(2) = String(10 - Len(Str(Id)), " ") + Str(Id)
  1104. NewItem.SubItems(3) = Str(Severity)
  1105. NewItem.SubItems(4) = Description
  1106. NewItem.SmallIcon = Severity
  1107. End Sub
  1108. Private Sub ExitMenuItem_Click()
  1109. Unload MainForm
  1110. End Sub
  1111. Private Function GenerateKeyName(ParentKey As String) As String
  1112. 'Keep trying until we fail on a key lookup, then we know we have a unique name
  1113. On Error GoTo LError
  1114. Dim Name As String
  1115. Dim Num As Long
  1116. Dim Hit As Node
  1117. Num = 0
  1118. Do
  1119. Num = Num + 1
  1120. Name = "NewKey" & Str(Num)
  1121. Set Hit = KeyTreeView.Nodes(ParentKey & "\" & Name)
  1122. Loop
  1123. LError:
  1124. GenerateKeyName = Name
  1125. End Function
  1126. Private Sub NewKeyMenuItem_Click()
  1127. Dim NewName As String
  1128. Dim NewNode As Node
  1129. If Not KeyTreeView.SelectedItem Is Nothing Then
  1130. 'Expand the parent
  1131. KeyTreeView.SelectedItem.Expanded = True
  1132. 'Create it
  1133. NewName = GenerateKeyName(KeyTreeView.SelectedItem.FullPath)
  1134. Set NewNode = KeyTreeView.Nodes.Add(KeyTreeView.SelectedItem, tvwChild, KeyTreeView.SelectedItem.FullPath & "\" & NewName, NewName)
  1135. NewNode.Key = NewNode.FullPath
  1136. NewNode.Image = 1
  1137. NewNode.ExpandedImage = 2
  1138. 'Set node as visited
  1139. NewNode.Tag = False
  1140. MetaUtilObj.CreateKey NewNode.FullPath
  1141. 'Select It
  1142. Set KeyTreeView.SelectedItem = NewNode
  1143. DataListView.ListItems.Clear
  1144. 'Edit it
  1145. KeyTreeView.StartLabelEdit
  1146. Else
  1147. MsgBox "No key selected", vbOKOnly + vbExclamation, "Rename Key"
  1148. End If
  1149. End Sub
  1150. Private Sub NewDwordMenuItem_Click()
  1151. If Not KeyTreeView.SelectedItem Is Nothing Then
  1152. 'Set the form parameters
  1153. SimpleEditForm.Machine = KeyTreeView.SelectedItem.Root.FullPath
  1154. SimpleEditForm.Key = KeyTreeView.SelectedItem.FullPath
  1155. SimpleEditForm.Id = 0
  1156. SimpleEditForm.NewDataType = DWORD_METADATA
  1157. 'Run it
  1158. SimpleEditForm.Init
  1159. SimpleEditForm.Show vbModal, Me
  1160. 'Refresh DataListView
  1161. RefreshData
  1162. Else
  1163. MsgBox "No key selected", vbOKOnly + vbExclamation, "New DWord"
  1164. End If
  1165. End Sub
  1166. Private Sub NewStringMenuItem_Click()
  1167. If Not KeyTreeView.SelectedItem Is Nothing Then
  1168. 'Set the form parameters
  1169. SimpleEditForm.Machine = KeyTreeView.SelectedItem.Root.FullPath
  1170. SimpleEditForm.Key = KeyTreeView.SelectedItem.FullPath
  1171. SimpleEditForm.Id = 0
  1172. SimpleEditForm.NewDataType = STRING_METADATA
  1173. 'Run it
  1174. SimpleEditForm.Init
  1175. SimpleEditForm.Show vbModal, Me
  1176. 'Refresh DataListView
  1177. RefreshData
  1178. Else
  1179. MsgBox "No key selected", vbOKOnly + vbExclamation, "New String"
  1180. End If
  1181. End Sub
  1182. Private Sub NewExpandStringMenuItem_Click()
  1183. If Not KeyTreeView.SelectedItem Is Nothing Then
  1184. 'Set the form parameters
  1185. SimpleEditForm.Machine = KeyTreeView.SelectedItem.Root.FullPath
  1186. SimpleEditForm.Key = KeyTreeView.SelectedItem.FullPath
  1187. SimpleEditForm.Id = 0
  1188. SimpleEditForm.NewDataType = EXPANDSZ_METADATA
  1189. 'Run it
  1190. SimpleEditForm.Init
  1191. SimpleEditForm.Show vbModal, Me
  1192. 'Refresh DataListView
  1193. RefreshData
  1194. Else
  1195. MsgBox "No key selected", vbOKOnly + vbExclamation, "New Expand String"
  1196. End If
  1197. End Sub
  1198. Private Sub NewBinaryMenuItem_Click()
  1199. If Not KeyTreeView.SelectedItem Is Nothing Then
  1200. 'Set the form parameters
  1201. SimpleEditForm.Machine = KeyTreeView.SelectedItem.Root.FullPath
  1202. SimpleEditForm.Key = KeyTreeView.SelectedItem.FullPath
  1203. SimpleEditForm.Id = 0
  1204. SimpleEditForm.NewDataType = BINARY_METADATA
  1205. 'Run it
  1206. SimpleEditForm.Init
  1207. SimpleEditForm.Show vbModal, Me
  1208. 'Refresh DataListView
  1209. RefreshData
  1210. Else
  1211. MsgBox "No key selected", vbOKOnly + vbExclamation, "New Expand String"
  1212. End If
  1213. End Sub
  1214. Private Sub NewMultiStringMenuItem_Click()
  1215. If Not KeyTreeView.SelectedItem Is Nothing Then
  1216. 'Set the form parameters
  1217. MultiEditForm.Machine = KeyTreeView.SelectedItem.Root.FullPath
  1218. MultiEditForm.Key = KeyTreeView.SelectedItem.FullPath
  1219. MultiEditForm.Id = 0
  1220. MultiEditForm.NewDataType = MULTISZ_METADATA
  1221. 'Run it
  1222. MultiEditForm.Init
  1223. MultiEditForm.Show vbModal, Me
  1224. 'Refresh DataListView
  1225. RefreshData
  1226. Else
  1227. MsgBox "No key selected", vbOKOnly + vbExclamation, "New Expand String"
  1228. End If
  1229. End Sub
  1230. Private Sub DeleteMenuItem_Click()
  1231. Dim Response As Long
  1232. If MainForm.ActiveControl Is KeyTreeView Then
  1233. Response = MsgBox("Are you sure you want to delete key " & KeyTreeView.SelectedItem.FullPath & "?", _
  1234. vbQuestion + vbYesNo, "Delete Key")
  1235. If Response = vbYes Then
  1236. MetaUtilObj.DeleteKey KeyTreeView.SelectedItem.FullPath
  1237. KeyTreeView.Nodes.Remove KeyTreeView.SelectedItem.Index
  1238. ShowSelectedNode
  1239. End If
  1240. ElseIf MainForm.ActiveControl Is DataListView Then
  1241. Response = MsgBox("Are you sure you want to delete property " & Trim(DataListView.SelectedItem.Text) & "?", _
  1242. vbQuestion + vbYesNo, "Delete Property")
  1243. If Response = vbYes Then
  1244. MetaUtilObj.DeleteProperty KeyTreeView.SelectedItem.FullPath, CLng(DataListView.SelectedItem.Text)
  1245. DataListView.Tag = ""
  1246. ShowSelectedNode
  1247. End If
  1248. End If
  1249. End Sub
  1250. Private Sub RenameKeyMenuItem_Click()
  1251. If Not KeyTreeView.SelectedItem Is Nothing Then
  1252. KeyTreeView.StartLabelEdit
  1253. Else
  1254. MsgBox "No key selected", vbOKOnly + vbExclamation, "Rename Key"
  1255. End If
  1256. End Sub
  1257. Private Sub CopyKeyMenuItem_Click()
  1258. If Not KeyTreeView.SelectedItem Is Nothing Then
  1259. 'Set the form parameters
  1260. CopyKeyForm.SourceKey = KeyTreeView.SelectedItem.FullPath
  1261. 'Run it
  1262. CopyKeyForm.Init
  1263. CopyKeyForm.Show vbModal, Me
  1264. 'Refresh DataListView
  1265. If CopyKeyForm.Moved Then
  1266. KeyTreeView.Nodes.Remove KeyTreeView.SelectedItem.Index
  1267. End If
  1268. RefreshKeys
  1269. RefreshData
  1270. Else
  1271. MsgBox "No key selected", vbOKOnly + vbExclamation, "Rename Key"
  1272. End If
  1273. End Sub
  1274. Private Sub FindMenuItem_Click()
  1275. FindForm.Show vbModal, Me
  1276. End Sub
  1277. Private Sub FindNextMenuItem_Click()
  1278. FindWorkingForm.Show vbModal, MainForm
  1279. End Sub
  1280. Private Sub CheckSchemaMenuItem_Click()
  1281. Dim CheckError As Variant
  1282. Dim NumErrors As Long
  1283. If Not KeyTreeView.SelectedItem Is Nothing Then
  1284. NumErrors = 0
  1285. 'Set the cursor to hourglass
  1286. AppCursor = vbHourglass
  1287. MainForm.MousePointer = AppCursor
  1288. 'Make sure the list is visible
  1289. If Not ErrorListView.Visible Then
  1290. ErrorListView.Visible = True
  1291. ErrorListMenuItem.Checked = True
  1292. LayoutForm
  1293. ErrorListView.Refresh
  1294. End If
  1295. 'Clear the error list
  1296. ErrorListView.ListItems.Clear
  1297. 'Add the errors to the list
  1298. For Each CheckError In MetaUtilObj.CheckSchema(KeyTreeView.SelectedItem.Root.FullPath)
  1299. AddErrorToErrorListView CheckError
  1300. NumErrors = NumErrors + 1
  1301. Next
  1302. 'Resort
  1303. ErrorListView.Sorted = True
  1304. 'Restore the cursor
  1305. AppCursor = vbDefault
  1306. MainForm.MousePointer = AppCursor
  1307. If NumErrors = 0 Then
  1308. MainStatusBar.SimpleText = "No errors found in schema."
  1309. Else
  1310. MainStatusBar.SimpleText = Str(NumErrors) & " errors found in schema."
  1311. End If
  1312. Else
  1313. MsgBox "No key selected", vbOKOnly + vbExclamation, "Check Schema"
  1314. End If
  1315. End Sub
  1316. Private Sub CheckKeyMenuItem_Click()
  1317. Dim CheckError As Variant
  1318. Dim NumErrors As Long
  1319. If Not KeyTreeView.SelectedItem Is Nothing Then
  1320. NumErrors = 0
  1321. 'Set the cursor to hourglass
  1322. AppCursor = vbHourglass
  1323. MainForm.MousePointer = AppCursor
  1324. 'Make sure the list is visible
  1325. If Not ErrorListView.Visible Then
  1326. ErrorListView.Visible = True
  1327. ErrorListMenuItem.Checked = True
  1328. LayoutForm
  1329. End If
  1330. 'Clear the error list
  1331. ErrorListView.ListItems.Clear
  1332. 'Add the errors to the list
  1333. For Each CheckError In MetaUtilObj.CheckKey(KeyTreeView.SelectedItem.FullPath)
  1334. AddErrorToErrorListView CheckError
  1335. NumErrors = NumErrors + 1
  1336. Next
  1337. 'Resort
  1338. ErrorListView.Sorted = True
  1339. 'Display the number of errors in the status bar
  1340. If NumErrors = 0 Then
  1341. MainStatusBar.SimpleText = "No errors found in " & KeyTreeView.SelectedItem.FullPath & "."
  1342. Else
  1343. MainStatusBar.SimpleText = Str(NumErrors) & " errors found in " & KeyTreeView.SelectedItem.FullPath & "."
  1344. End If
  1345. 'Restore the cursor
  1346. AppCursor = vbDefault
  1347. MainForm.MousePointer = AppCursor
  1348. Else
  1349. MsgBox "No key selected", vbOKOnly + vbExclamation, "Check Key"
  1350. End If
  1351. End Sub
  1352. Private Sub CheckAllMenuItem_Click()
  1353. Dim CheckError As Variant
  1354. Dim Key As Variant
  1355. Dim NumErrors As Long
  1356. NumErrors = 0
  1357. 'Set the cursor to hourglass
  1358. AppCursor = vbHourglass
  1359. MainForm.MousePointer = AppCursor
  1360. 'Make sure the list is visible
  1361. If Not ErrorListView.Visible Then
  1362. ErrorListView.Visible = True
  1363. ErrorListMenuItem.Checked = True
  1364. LayoutForm
  1365. End If
  1366. 'Clear the error list
  1367. ErrorListView.ListItems.Clear
  1368. 'Add the errors to the list
  1369. For Each Key In MetaUtilObj.EnumAllKeys("")
  1370. For Each CheckError In MetaUtilObj.CheckKey(Key)
  1371. AddErrorToErrorListView CheckError
  1372. NumErrors = NumErrors + 1
  1373. Next
  1374. Next
  1375. 'Resort
  1376. ErrorListView.Sorted = True
  1377. 'Display the number of errors in the status bar
  1378. If NumErrors = 0 Then
  1379. MainStatusBar.SimpleText = "No errors found outside of schema."
  1380. Else
  1381. MainStatusBar.SimpleText = Str(NumErrors) & " errors found outside of schema."
  1382. End If
  1383. 'Restore the cursor
  1384. AppCursor = vbDefault
  1385. MainForm.MousePointer = AppCursor
  1386. End Sub
  1387. Private Sub CheckOptionsMenuItem_Click()
  1388. CheckOptionsForm.Init
  1389. CheckOptionsForm.Show vbModal, Me
  1390. End Sub
  1391. Private Sub ErrorListMenuItem_Click()
  1392. If ErrorListView.Visible Then
  1393. ErrorListView.Visible = False
  1394. ErrorListMenuItem.Checked = False
  1395. Else
  1396. ErrorListView.Visible = True
  1397. ErrorListMenuItem.Checked = True
  1398. End If
  1399. LayoutForm
  1400. End Sub
  1401. Private Sub StatusBarMenuItem_Click()
  1402. If MainStatusBar.Visible Then
  1403. Config.StatusBar = False
  1404. MainStatusBar.Visible = False
  1405. StatusBarMenuItem.Checked = False
  1406. Else
  1407. Config.StatusBar = True
  1408. MainStatusBar.Visible = True
  1409. StatusBarMenuItem.Checked = True
  1410. End If
  1411. LayoutForm
  1412. End Sub
  1413. Private Sub RefreshMenuItem_Click()
  1414. Dim SelectedControl As Control
  1415. Dim SelectedProperty As String
  1416. 'Save the focus
  1417. Set SelectedControl = MainForm.ActiveControl
  1418. 'Save the selected property
  1419. If DataListView.SelectedItem Is Nothing Then
  1420. SelectedProperty = ""
  1421. Else
  1422. SelectedProperty = DataListView.SelectedItem.Text
  1423. End If
  1424. 'Reload
  1425. RefreshKeys
  1426. RefreshData
  1427. 'Restore the selected property
  1428. If SelectedProperty <> "" Then
  1429. SelectProperty SelectedProperty
  1430. End If
  1431. 'Restore original focus
  1432. If Not SelectedControl Is Nothing Then
  1433. SelectedControl.SetFocus
  1434. End If
  1435. End Sub
  1436. Private Sub AboutMenuItem_Click()
  1437. Load AboutForm
  1438. AboutForm.Show vbModal, Me
  1439. End Sub
  1440. Private Sub ExpandKeyMenuItem_Click()
  1441. If Not KeyTreeView.SelectedItem Is Nothing Then
  1442. KeyTreeView.SelectedItem.Expanded = True
  1443. End If
  1444. End Sub
  1445. Private Sub KeyNewKeyMenuItem_Click()
  1446. 'Redirect
  1447. NewKeyMenuItem_Click
  1448. End Sub
  1449. Private Sub KeyNewDwordMenuItem_Click()
  1450. 'Redirect
  1451. NewDwordMenuItem_Click
  1452. End Sub
  1453. Private Sub KeyNewStringMenuItem_Click()
  1454. 'Redirect
  1455. NewStringMenuItem_Click
  1456. End Sub
  1457. Private Sub KeyNewBinaryMenuItem_Click()
  1458. 'Redirect
  1459. NewBinaryMenuItem_Click
  1460. End Sub
  1461. Private Sub KeyNewExpandSzMenuItem_Click()
  1462. 'Redirect
  1463. NewExpandStringMenuItem_Click
  1464. End Sub
  1465. Private Sub KeyNewMultiSzMenuItem_Click()
  1466. 'Redirect
  1467. NewMultiStringMenuItem_Click
  1468. End Sub
  1469. Private Sub KeyDeleteMenuItem_Click()
  1470. 'Redirect
  1471. DeleteMenuItem_Click
  1472. End Sub
  1473. Private Sub KeyRenameMenuItem_Click()
  1474. 'Redirect
  1475. RenameKeyMenuItem_Click
  1476. End Sub
  1477. Private Sub KeyCopyMenuItem_Click()
  1478. 'Redirect
  1479. CopyKeyMenuItem_Click
  1480. End Sub
  1481. Private Sub KeyCheckMenuItem_Click()
  1482. 'Redirect
  1483. CheckKeyMenuItem_Click
  1484. End Sub
  1485. Private Sub DataModifyMenuItem_Click()
  1486. 'Redirect
  1487. DataListView_DblClick
  1488. End Sub
  1489. Private Sub DataNewDwordMenuItem_Click()
  1490. 'Redirect
  1491. NewDwordMenuItem_Click
  1492. End Sub
  1493. Private Sub DataNewStringMenuItem_Click()
  1494. 'Redirect
  1495. NewStringMenuItem_Click
  1496. End Sub
  1497. Private Sub DataNewBinaryMenuItem_Click()
  1498. 'Redirect
  1499. NewBinaryMenuItem_Click
  1500. End Sub
  1501. Private Sub DataNewExpandSzMenuItem_Click()
  1502. 'Redirect
  1503. NewExpandStringMenuItem_Click
  1504. End Sub
  1505. Private Sub DataNewMultiSzMenuItem_Click()
  1506. 'Redirect
  1507. NewMultiStringMenuItem_Click
  1508. End Sub
  1509. Private Sub DataDeleteMenuItem_Click()
  1510. 'Redirect
  1511. DeleteMenuItem_Click
  1512. End Sub