Leaked source code of windows server 2003
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.

973 lines
38 KiB

  1. VERSION 5.00
  2. Begin {B3E55942-FFD8-11D1-9788-44A620524153} DriveStats
  3. ClientHeight = 8970
  4. ClientLeft = 0
  5. ClientTop = 0
  6. ClientWidth = 10515
  7. _ExtentX = 18547
  8. _ExtentY = 15822
  9. m_iNextNodeNumber= 2
  10. Persistence.MajorVersion= 0
  11. Persistence.MinorVersion= 12
  12. BeginProperty ImageLists {FFF9A8F6-06CB-11D2-9791-50C320524153}
  13. Persistence.MajorVersion= 0
  14. Persistence.MinorVersion= 12
  15. Count = 0
  16. KeysOnly = 0
  17. EndProperty
  18. BeginProperty Menus {11517450-27FE-11D3-AA41-00104B880587}
  19. Persistence.MajorVersion= 0
  20. Persistence.MinorVersion= 12
  21. Count = 1
  22. KeysOnly = 0
  23. BeginProperty Item1 {91CC37D5-CE2B-11D1-B44D-7E92AF000000}
  24. Persistence.MajorVersion= 0
  25. Persistence.MinorVersion= 12
  26. Caption = "Menu1"
  27. Visible = -1
  28. Checked = 0
  29. Enabled = -1
  30. Grayed = 0
  31. MenuBreak = 0
  32. MenuBarBreak = 0
  33. Default = 0
  34. Index = 1
  35. Name = "mnuChooseDrive"
  36. StatusBarText = ""
  37. BeginProperty Children {11517450-27FE-11D3-AA41-00104B880587}
  38. Persistence.MajorVersion= 0
  39. Persistence.MinorVersion= 12
  40. Count = 1
  41. KeysOnly = 0
  42. BeginProperty Item1 {91CC37D5-CE2B-11D1-B44D-7E92AF000000}
  43. Persistence.MajorVersion= 0
  44. Persistence.MinorVersion= 12
  45. Caption = "Choose drive"
  46. Visible = -1
  47. Checked = 0
  48. Enabled = -1
  49. Grayed = 0
  50. MenuBreak = 0
  51. MenuBarBreak = 0
  52. Default = 0
  53. Index = 1
  54. Name = "mnuChooseTask"
  55. StatusBarText = ""
  56. BeginProperty Children {11517450-27FE-11D3-AA41-00104B880587}
  57. Persistence.MajorVersion= 0
  58. Persistence.MinorVersion= 12
  59. Count = 0
  60. KeysOnly = 0
  61. EndProperty
  62. Key = "Menu1"
  63. DISPID = 1001
  64. EndProperty
  65. EndProperty
  66. Key = "Menu1"
  67. DISPID = 1000
  68. EndProperty
  69. EndProperty
  70. BeginProperty Toolbars {FFF9A8FA-06CB-11D2-9791-50C320524153}
  71. Persistence.MajorVersion= 0
  72. Persistence.MinorVersion= 12
  73. Count = 0
  74. KeysOnly = 0
  75. EndProperty
  76. BeginProperty ViewDefs {FFF9A8E1-06CB-11D2-9791-50C320524153}
  77. Persistence.MajorVersion= 0
  78. Persistence.MinorVersion= 12
  79. BeginProperty ListViews {FFF9A8FC-06CB-11D2-9791-50C320524153}
  80. Persistence.MajorVersion= 0
  81. Persistence.MinorVersion= 12
  82. Count = 1
  83. KeysOnly = 0
  84. BeginProperty Item1 {FFF9A8EC-06CB-11D2-9791-50C320524153}
  85. Persistence.MajorVersion= 0
  86. Persistence.MinorVersion= 12
  87. Index = 1
  88. Key = "lvDriveStats"
  89. Name = "lvDriveStats"
  90. AddToViewMenu = 0
  91. ViewMenuText = ""
  92. ViewMenuStatusBarText= ""
  93. DefaultItemTypeGUID= "{BD7F7140-A8A4-11D2-97E5-00104B880587}"
  94. Extensible = 0
  95. BeginProperty ListView {87BC180F-C8FB-11D1-B44A-30F4BC000000}
  96. Persistence.MajorVersion= 0
  97. Persistence.MinorVersion= 12
  98. BeginProperty ColumnHeaders {3B15D611-CD57-11D1-B44C-44750B000000}
  99. Persistence.MajorVersion= 0
  100. Persistence.MinorVersion= 12
  101. Count = 2
  102. KeysOnly = 0
  103. BeginProperty Item1 {3B15D613-CD57-11D1-B44C-44750B000000}
  104. Persistence.MajorVersion= 0
  105. Persistence.MinorVersion= 12
  106. Index = 1
  107. Key = "Stat"
  108. Tag = 0
  109. Text = "Stat"
  110. Object.Width = 120
  111. Alignment = 0
  112. Hidden = 0
  113. TextFilter = ""
  114. TextFilterMaxLen= 260
  115. NumericFilter = ""
  116. EndProperty
  117. BeginProperty Item2 {3B15D613-CD57-11D1-B44C-44750B000000}
  118. Persistence.MajorVersion= 0
  119. Persistence.MinorVersion= 12
  120. Index = 2
  121. Key = "Value"
  122. Tag = 0
  123. Text = "Value"
  124. Object.Width = 120
  125. Alignment = 0
  126. Hidden = 0
  127. TextFilter = ""
  128. TextFilterMaxLen= 260
  129. NumericFilter = ""
  130. EndProperty
  131. EndProperty
  132. Icons = ""
  133. SmallIcons = ""
  134. Sorted = 0
  135. SortKey = 0
  136. SortOrder = 0
  137. View = 3
  138. Tag = 0
  139. Virtual = 0
  140. UseFontLinking = 0
  141. MultiSelect = 0
  142. HideSelection = 0
  143. SortHeader = -1
  144. SortIcon = -1
  145. FilterChangeTimeout= 500
  146. ShowChildScopeItems= -1
  147. LexicalSort = 0
  148. EndProperty
  149. EndProperty
  150. EndProperty
  151. BeginProperty OCXViews {FFF9A8FF-06CB-11D2-9791-50C320524153}
  152. Persistence.MajorVersion= 0
  153. Persistence.MinorVersion= 12
  154. Count = 0
  155. KeysOnly = 0
  156. EndProperty
  157. BeginProperty URLViews {FFF9A902-06CB-11D2-9791-50C320524153}
  158. Persistence.MajorVersion= 0
  159. Persistence.MinorVersion= 12
  160. Count = 0
  161. KeysOnly = 0
  162. EndProperty
  163. BeginProperty TaskpadViews {FFF9A904-06CB-11D2-9791-50C320524153}
  164. Persistence.MajorVersion= 0
  165. Persistence.MinorVersion= 12
  166. Count = 1
  167. KeysOnly = 0
  168. BeginProperty Item1 {FFF9A8F2-06CB-11D2-9791-50C320524153}
  169. Persistence.MajorVersion= 0
  170. Persistence.MinorVersion= 12
  171. Name = "StatsListpad"
  172. Index = 1
  173. Key = "StatsListpad"
  174. AddToViewMenu = 0
  175. ViewMenuText = ""
  176. ViewMenuStatusBarText= ""
  177. UseWhenTaskpadViewPreferred= 0
  178. BeginProperty Taskpad {861481F2-D867-11D1-B450-C43058000000}
  179. Persistence.MajorVersion= 0
  180. Persistence.MinorVersion= 12
  181. Name = "StatsListpad"
  182. Type = 4
  183. Title = "Drive Statistics"
  184. URL = ""
  185. DescriptiveText = "DriveStats Dynamic Namespace Extension"
  186. BackgroundType = 0
  187. MouseOverImage = ""
  188. MouseOffImage = ""
  189. FontFamily = ""
  190. EOTFile = ""
  191. SymbolString = ""
  192. ListpadStyle = 1
  193. ListpadTitle = ""
  194. ListpadHasButton= -1
  195. ListpadButtonText= "Change..."
  196. ListView = "lvDriveStats"
  197. BeginProperty Tasks {861481F4-D867-11D1-B450-C43058000000}
  198. Persistence.MajorVersion= 0
  199. Persistence.MinorVersion= 12
  200. Count = 0
  201. KeysOnly = 0
  202. EndProperty
  203. EndProperty
  204. EndProperty
  205. EndProperty
  206. EndProperty
  207. BeginProperty DataFormats {91FE14C5-7370-11D2-97D8-00104B880587}
  208. Persistence.MajorVersion= 0
  209. Persistence.MinorVersion= 12
  210. Count = 0
  211. KeysOnly = 0
  212. EndProperty
  213. BeginProperty SnapInDef {FFF9A8E4-06CB-11D2-9791-50C320524153}
  214. Persistence.MajorVersion= 0
  215. Persistence.MinorVersion= 12
  216. Name = "DriveStats"
  217. NodeTypeName = "DriveStats"
  218. NodeTypeGUID = "{D42F4542-CD95-11d2-97ED-00104B880587}"
  219. DisplayName = "DriveStats"
  220. Type = 1
  221. HelpFile = ""
  222. LinkedTopics = ""
  223. Description = "Description of your snap-in"
  224. Provider = "Microsoft Corporation"
  225. Version = "1.0"
  226. SmallFolders = ""
  227. SmallFoldersOpen= ""
  228. LargeFolders = ""
  229. Icon = "DriveStats.dsx":0000
  230. Watermark = "DriveStats.dsx":005E
  231. Header = "DriveStats.dsx":00BC
  232. Palette = "DriveStats.dsx":011A
  233. StretchWatermark= 0
  234. StaticFolder = 0
  235. DefaultView = ""
  236. Extensible = 0
  237. BeginProperty ViewDefs {FFF9A8E1-06CB-11D2-9791-50C320524153}
  238. Persistence.MajorVersion= 0
  239. Persistence.MinorVersion= 12
  240. BeginProperty ListViews {FFF9A8FC-06CB-11D2-9791-50C320524153}
  241. Persistence.MajorVersion= 0
  242. Persistence.MinorVersion= 12
  243. Count = 0
  244. KeysOnly = 1
  245. EndProperty
  246. BeginProperty OCXViews {FFF9A8FF-06CB-11D2-9791-50C320524153}
  247. Persistence.MajorVersion= 0
  248. Persistence.MinorVersion= 12
  249. Count = 0
  250. KeysOnly = 1
  251. EndProperty
  252. BeginProperty URLViews {FFF9A902-06CB-11D2-9791-50C320524153}
  253. Persistence.MajorVersion= 0
  254. Persistence.MinorVersion= 12
  255. Count = 0
  256. KeysOnly = 1
  257. EndProperty
  258. BeginProperty TaskpadViews {FFF9A904-06CB-11D2-9791-50C320524153}
  259. Persistence.MajorVersion= 0
  260. Persistence.MinorVersion= 12
  261. Count = 0
  262. KeysOnly = 1
  263. EndProperty
  264. EndProperty
  265. BeginProperty Children {FFF9A8F4-06CB-11D2-9791-50C320524153}
  266. Persistence.MajorVersion= 0
  267. Persistence.MinorVersion= 12
  268. Count = 0
  269. KeysOnly = 0
  270. EndProperty
  271. IID = "{AE9CA206-D929-466E-ADE1-CBBF0F9F1C84}"
  272. Preload = 0
  273. EndProperty
  274. BeginProperty ExtensionDefs {FFF9A8E6-06CB-11D2-9791-50C320524153}
  275. Persistence.MajorVersion= 0
  276. Persistence.MinorVersion= 12
  277. ExtendsNewMenu = 0
  278. ExtendsTaskMenu = 0
  279. ExtendsTopMenu = 0
  280. ExtendsViewMenu = 0
  281. ExtendsPropertyPages= 0
  282. ExtendsToolbar = 0
  283. ExtendsNameSpace= 0
  284. BeginProperty ExtendedSnapIns {BDA4B9D1-0872-11D2-9791-50C320524153}
  285. Persistence.MajorVersion= 0
  286. Persistence.MinorVersion= 12
  287. Count = 2
  288. KeysOnly = 0
  289. BeginProperty Item1 {FFF9A8E8-06CB-11D2-9791-50C320524153}
  290. Persistence.MajorVersion= 0
  291. Persistence.MinorVersion= 12
  292. Name = ""
  293. Index = 1
  294. Key = "{119067F7-4DBC-11D2-8873-0080C7E0ACE4}"
  295. CLSID = "{119067F7-4DBC-11D2-8873-0080C7E0ACE4}"
  296. DisplayName = "Directory"
  297. Dynamic = -1
  298. ExtendsNameSpace= -1
  299. ExtendsNewMenu = 0
  300. ExtendsTaskMenu = 0
  301. ExtendsPropertyPages= 0
  302. ExtendsToolbar = 0
  303. ExtendsTaskpad = 0
  304. EndProperty
  305. BeginProperty Item2 {FFF9A8E8-06CB-11D2-9791-50C320524153}
  306. Persistence.MajorVersion= 0
  307. Persistence.MinorVersion= 12
  308. Name = ""
  309. Index = 2
  310. Key = "{119067B6-4DBC-11D2-8873-0080C7E0ACE4}"
  311. CLSID = "{119067B6-4DBC-11D2-8873-0080C7E0ACE4}"
  312. DisplayName = "MyComputer"
  313. Dynamic = -1
  314. ExtendsNameSpace= -1
  315. ExtendsNewMenu = 0
  316. ExtendsTaskMenu = 0
  317. ExtendsPropertyPages= 0
  318. ExtendsToolbar = 0
  319. ExtendsTaskpad = 0
  320. EndProperty
  321. EndProperty
  322. EndProperty
  323. BeginProperty AutoCreateNodes {FFF9A8F4-06CB-11D2-9791-50C320524153}
  324. Persistence.MajorVersion= 0
  325. Persistence.MinorVersion= 12
  326. Count = 0
  327. KeysOnly = 0
  328. EndProperty
  329. BeginProperty OtherNodes {FFF9A8F4-06CB-11D2-9791-50C320524153}
  330. Persistence.MajorVersion= 0
  331. Persistence.MinorVersion= 12
  332. Count = 2
  333. KeysOnly = 0
  334. BeginProperty Item1 {FFF9A8EA-06CB-11D2-9791-50C320524153}
  335. Persistence.MajorVersion= 0
  336. Persistence.MinorVersion= 12
  337. Name = "DriveStats"
  338. Index = 1
  339. Key = "DriveStats"
  340. NodeTypeName = "DriveStats"
  341. NodeTypeGUID = "{BD7F713F-A8A4-11D2-97E5-00104B880587}"
  342. DisplayName = "<Stats>"
  343. Folder = "0"
  344. DefaultDataFormat= ""
  345. AutoCreate = 0
  346. DefaultView = "lvDriveStats"
  347. HasChildren = -1
  348. Extensible = 0
  349. BeginProperty ViewDefs {FFF9A8E1-06CB-11D2-9791-50C320524153}
  350. Persistence.MajorVersion= 0
  351. Persistence.MinorVersion= 12
  352. BeginProperty ListViews {FFF9A8FC-06CB-11D2-9791-50C320524153}
  353. Persistence.MajorVersion= 0
  354. Persistence.MinorVersion= 12
  355. Count = 1
  356. KeysOnly = 1
  357. Item1 = "lvDriveStats"
  358. EndProperty
  359. BeginProperty OCXViews {FFF9A8FF-06CB-11D2-9791-50C320524153}
  360. Persistence.MajorVersion= 0
  361. Persistence.MinorVersion= 12
  362. Count = 0
  363. KeysOnly = 1
  364. EndProperty
  365. BeginProperty URLViews {FFF9A902-06CB-11D2-9791-50C320524153}
  366. Persistence.MajorVersion= 0
  367. Persistence.MinorVersion= 12
  368. Count = 0
  369. KeysOnly = 1
  370. EndProperty
  371. BeginProperty TaskpadViews {FFF9A904-06CB-11D2-9791-50C320524153}
  372. Persistence.MajorVersion= 0
  373. Persistence.MinorVersion= 12
  374. Count = 0
  375. KeysOnly = 1
  376. EndProperty
  377. EndProperty
  378. BeginProperty Children {FFF9A8F4-06CB-11D2-9791-50C320524153}
  379. Persistence.MajorVersion= 0
  380. Persistence.MinorVersion= 12
  381. Count = 0
  382. KeysOnly = 0
  383. EndProperty
  384. Tag = 0
  385. BeginProperty ColumnHeaders {3B15D611-CD57-11D1-B44C-44750B000000}
  386. Persistence.MajorVersion= 0
  387. Persistence.MinorVersion= 12
  388. Count = 0
  389. KeysOnly = 0
  390. EndProperty
  391. EndProperty
  392. BeginProperty Item2 {FFF9A8EA-06CB-11D2-9791-50C320524153}
  393. Persistence.MajorVersion= 0
  394. Persistence.MinorVersion= 12
  395. Name = "MyComputerStats"
  396. Index = 2
  397. Key = "MyComputerStats"
  398. NodeTypeName = "MyComputerStats"
  399. NodeTypeGUID = "{817721E0-2A99-11D3-AA41-00104B880587}"
  400. DisplayName = "<Stats>"
  401. Folder = ""
  402. DefaultDataFormat= ""
  403. AutoCreate = 0
  404. DefaultView = "StatsListpad"
  405. HasChildren = -1
  406. Extensible = -1
  407. BeginProperty ViewDefs {FFF9A8E1-06CB-11D2-9791-50C320524153}
  408. Persistence.MajorVersion= 0
  409. Persistence.MinorVersion= 12
  410. BeginProperty ListViews {FFF9A8FC-06CB-11D2-9791-50C320524153}
  411. Persistence.MajorVersion= 0
  412. Persistence.MinorVersion= 12
  413. Count = 1
  414. KeysOnly = 1
  415. Item1 = "lvDriveStats"
  416. EndProperty
  417. BeginProperty OCXViews {FFF9A8FF-06CB-11D2-9791-50C320524153}
  418. Persistence.MajorVersion= 0
  419. Persistence.MinorVersion= 12
  420. Count = 0
  421. KeysOnly = 1
  422. EndProperty
  423. BeginProperty URLViews {FFF9A902-06CB-11D2-9791-50C320524153}
  424. Persistence.MajorVersion= 0
  425. Persistence.MinorVersion= 12
  426. Count = 0
  427. KeysOnly = 1
  428. EndProperty
  429. BeginProperty TaskpadViews {FFF9A904-06CB-11D2-9791-50C320524153}
  430. Persistence.MajorVersion= 0
  431. Persistence.MinorVersion= 12
  432. Count = 1
  433. KeysOnly = 1
  434. Item1 = "StatsListpad"
  435. EndProperty
  436. EndProperty
  437. BeginProperty Children {FFF9A8F4-06CB-11D2-9791-50C320524153}
  438. Persistence.MajorVersion= 0
  439. Persistence.MinorVersion= 12
  440. Count = 0
  441. KeysOnly = 0
  442. EndProperty
  443. BeginProperty ColumnHeaders {3B15D611-CD57-11D1-B44C-44750B000000}
  444. Persistence.MajorVersion= 0
  445. Persistence.MinorVersion= 12
  446. Count = 0
  447. KeysOnly = 0
  448. EndProperty
  449. EndProperty
  450. EndProperty
  451. TypeinfoCookie = 47
  452. ProjectName = "DriveStatsProj"
  453. End
  454. Attribute VB_Name = "DriveStats"
  455. Attribute VB_GlobalNameSpace = False
  456. Attribute VB_Creatable = True
  457. Attribute VB_PredeclaredId = False
  458. Attribute VB_Exposed = True
  459. Option Explicit
  460. ' ===========================================================================
  461. ' | THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF |
  462. ' | ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO |
  463. ' | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A |
  464. ' | PARTICULAR PURPOSE. |
  465. ' | Copyright (c) 1998-1999 Microsoft Corporation |
  466. ' ===========================================================================
  467. ' =============================================================================
  468. ' File: DriveStats.dsr
  469. ' Project: DriveStatsProj
  470. ' Type: SnapIn Designer
  471. ' =============================================================================
  472. ' =============================================================================
  473. ' Method: ExtensionSnapIn_Expand
  474. ' Type: Event
  475. ' Description: Fired when a context menu is about to be displayed to give the
  476. ' extension snap-in the opportunity to add items to MMC's "Task"
  477. ' sub-menu.
  478. '
  479. ' Parameters: Data An MMCDataObject containing data exported by
  480. ' the expanding node owned by the extended snap-in.
  481. ' The extensions snap-in must interpret the data
  482. ' exported by the extended snap-in (in this case
  483. ' FileExplorer exports the data).
  484. ' ScopeNode Object representing the expanding node. Used
  485. ' as the parent node if the extension decides to
  486. ' extend the namespace by adding a child node.
  487. ' Output: None
  488. ' Notes: If the expanding node is a FileExplorer drive then adds a child
  489. ' node called "<Stats>".
  490. ' If the expanding node is FileExplorer's "My Computer" node then
  491. ' add our MyComputerStats node.
  492. ' =============================================================================
  493. '
  494. Private Sub ExtensionSnapIn_Expand(ByVal Data As SnapInLib.IMMCDataObject, _
  495. ByVal ScopeNode As SnapInLib.IScopeNode)
  496. On Error GoTo ErrTrap_ExtensionSnapIn_Expand
  497. Dim DriveName As String
  498. Dim DriveScopeItem As ScopeItem
  499. Dim DrivesScopeItem As ScopeItem
  500. ' FileExplorer exports a format called "Drive" for drive nodes. If it is there
  501. ' then add our <Stats> node underneath it.
  502. If Data.GetFormat("Drive") Then
  503. ' It is a drive node. Get the name of the drive from the exported data.
  504. DriveName = Data.GetData("Drive")
  505. ' Add our scope item to the namespace and set its tag to the drive name
  506. Set DriveScopeItem = ScopeItems.AddPreDefined("DriveStats", DriveName, ScopeNode, siParent)
  507. DriveScopeItem.Tag = DriveName
  508. ' Add a single column called "<Stats>" for when this scope item is displayed
  509. ' in the result pane in report mode. In that case the designer runtime will use the
  510. ' column number to index ScopeItem.ListSubItems. This ensures that the word
  511. ' "<Stats>" will always appear in the first column. Other columns will not contain
  512. ' anything. Note also that unlike a standalone snap-in there is no need to define
  513. ' column headers for the scope item as the column names of the extended snap-in
  514. ' are not available to the runtime.
  515. DriveScopeItem.ListSubItems.Add 1, 1, "<Stats>"
  516. ElseIf Data.GetFormat("DriveNames") Then
  517. ' FileExplorer exports a format called "DriveNames" for its "My Computer" node
  518. ' Add our MyComputerStats node underneath it and set its tag to the drive name
  519. ' array exported from FileExplorer
  520. Set DrivesScopeItem = ScopeItems.AddPreDefined("MyComputerStats", "MyComputerStats", ScopeNode, siParent)
  521. DrivesScopeItem.Tag = FormatData(Data.GetData("DriveNames"), 1, siMultiString)
  522. DrivesScopeItem.ListSubItems.Add 1, 1, "<Stats>"
  523. End If
  524. Exit Sub
  525. ' Error Handler for this method
  526. ErrTrap_ExtensionSnapIn_Expand:
  527. DisplayError "ExtensionSnapIn_Expand"
  528. End Sub
  529. ' =============================================================================
  530. ' Method: ResultViews_Deactivate
  531. ' Type: Event
  532. ' Description: Fired when the result pane is being torn down.
  533. '
  534. ' Parameters: ResultView The ResultView about to be destroyed.
  535. ' Keep Defaults to False to indicate that the ResultView
  536. ' object should be destroyed. Set to True to keep
  537. ' the object alive so that it can be reused if the
  538. ' scope pane item is ever reselected.
  539. ' Output: None
  540. ' Notes: As an example, keep the ResultView alive.
  541. ' =============================================================================
  542. '
  543. Private Sub ResultViews_Deactivate(ByVal ResultView As SnapInLib.IResultView, _
  544. Keep As Boolean)
  545. ' It can be very expensive to populate the listview because certain drive stats
  546. ' take some time to gather (e.g. on net drives over a slow connection) so we keep
  547. ' the result view alive in case the user decides to look at it again. In order to
  548. ' make this work we also need to handle ScopePaneItems_GetResultView to tell the
  549. ' runtime to reuse the existing one.
  550. Keep = True
  551. End Sub
  552. ' =============================================================================
  553. ' Method: ResultViews_ListpadButtonClick
  554. ' Type: Event
  555. ' Description: Fired when the "Change..." button is clicked on the listpad
  556. '
  557. ' Parameters: ResultView The ResultView about to be destroyed.
  558. '
  559. ' Output: None
  560. '
  561. ' Notes: Displays a form with a listbox of available drives and allows
  562. ' the user to select a drive. If the user selects a drive
  563. ' then clears out the listpad's list view and repopulates it
  564. ' with the drive's statistics.
  565. ' =============================================================================
  566. '
  567. Private Sub ResultViews_ListpadButtonClick(ByVal ResultView As SnapInLib.ResultView)
  568. On Error GoTo ErrTrap_ResultViews_ListpadButtonClick
  569. Dim frm As New frmChooseDrive
  570. Dim DriveNames() As String
  571. ' Get the drive names array we stored in our MyComputerStats ScopeItem's
  572. ' Tag during ExtensionSnapIn_Expand.
  573. DriveNames = ScopeItems("MyComputerStats").Tag
  574. ' Load the form, give it the list of drive names and the index of the
  575. ' currently displayed drive. Show the form as a modal dialog.
  576. ' Get the index of the currently displayed drive in the ResultView's Tag.
  577. Load frm
  578. frm.SetDriveNames DriveNames, ResultView.Tag
  579. frm.Show vbModal
  580. ' If the user clicked OK then get the index of the chosen drive and
  581. ' check if it is ready. If it is ready then clear out the listpad's
  582. ' list view and repopulate it with the drive's statistics.
  583. ' Store the index of the chosen drive in the ResultView's Tag.
  584. If frm.OK Then
  585. ChangeDrive DriveNames(frm.DriveChosen), frm.DriveChosen
  586. End If
  587. Exit Sub
  588. ' Error Handler for this method
  589. ErrTrap_ResultViews_ListpadButtonClick:
  590. DisplayError "ResultViews_ListpadButtonClick"
  591. End Sub
  592. Private Sub ChangeDrive(DriveName As String, Index As Integer)
  593. On Error GoTo ErrTrap_ChangeDrive
  594. Dim drv As Scripting.Drive
  595. Dim fs As New Scripting.FileSystemObject
  596. Set drv = fs.GetDrive(DriveName)
  597. If drv.IsReady Then
  598. With CurrentResultView
  599. .ListView.ListItems.Clear
  600. DisplayDriveStats DriveName, .ListView.ListItems
  601. .Tag = Index
  602. End With
  603. Else
  604. ConsoleMsgBox "Drive " & DriveName & " is not ready. Please choose another drive", vbOK, "DriveStats"
  605. End If
  606. Exit Sub
  607. ' Error Handler for this method
  608. ErrTrap_ChangeDrive:
  609. DisplayError "ChangeDrive"
  610. End Sub
  611. ' =============================================================================
  612. ' Method: ScopePaneItems_GetResultView
  613. ' Type: Event
  614. ' Description: Fired when the result pane is about to be shown. Allows the
  615. ' snap-in to reuse a ResultView kept alive in an earlier
  616. ' ResultViews_Deactivate event.
  617. '
  618. ' Parameters: ScopePaneItem The ScopePaneItem that has been selected and
  619. ' for which the result pane is about to be shown.
  620. ' Index If the snap-in wishes to reuse an existing
  621. ' ResultView it should return its index within
  622. ' ScopePaneItem.ResultViews here.
  623. ' Output: None
  624. ' Notes: As an example, keep the ResultView alive.
  625. ' =============================================================================
  626. '
  627. Private Sub ScopePaneItems_GetResultView(ByVal ScopePaneItem As SnapInLib.IScopePaneItem, _
  628. Index As Variant)
  629. On Error GoTo ErrTrap_ScopePaneItems_GetResultView
  630. ' If there is an existing result view then use it. There can only be one so
  631. ' we know its index
  632. If ScopePaneItem.ResultViews.Count > 0 Then
  633. Index = 1
  634. End If
  635. Exit Sub
  636. ' Error Handler for this method
  637. ErrTrap_ScopePaneItems_GetResultView:
  638. DisplayError "ScopePaneItems_GetResultView"
  639. End Sub
  640. ' =============================================================================
  641. ' Method: ResultViews_Initialize
  642. ' Type: Event
  643. ' Description: Fired when a new ResultView is created.
  644. ' Parameters: ResultView A reference to the specific ResultView object
  645. ' being initialized
  646. ' Output: None
  647. ' Notes: This is the event used to trigger population of the ResultView.
  648. ' It only occurs as a ResultView is being created. It is not
  649. ' fired in response to changing the view mode. However, in normal
  650. ' operation, a ResultView's ListItems are destroyed when a new
  651. ' ResultView is activated. ResultViews are not cached by default.
  652. ' =============================================================================
  653. '
  654. Private Sub ResultViews_Initialize(ByVal ResultView As SnapInLib.IResultView)
  655. On Error GoTo ErrTrap_ResultViews_Initialize
  656. Dim DriveName As String
  657. Dim DriveNames() As String
  658. Dim drv As Scripting.Drive
  659. Dim fs As New Scripting.FileSystemObject
  660. Dim i As Integer
  661. ' If this is a <Stats> node under a FileExplorer drive we stored the drive name as the
  662. ' scope item's tag. If it is a <Stats> node under FileExplorer's "My Computer" node
  663. ' then the scope item's tag contains the array of drive names that FileExplorer is
  664. ' displaying. Check for the first ready drive in the array and get its name.
  665. With ResultView.ScopePaneItem.ScopeItem
  666. If ResultView.ScopePaneItem.ScopeItem.Name = "MyComputerStats" Then
  667. DriveNames = .Tag
  668. For i = LBound(DriveNames) To UBound(DriveNames)
  669. Set drv = fs.GetDrive(DriveNames(i))
  670. If drv.IsReady Then
  671. DriveName = DriveNames(i)
  672. Exit For
  673. End If
  674. Next i
  675. Else
  676. DriveName = .Tag
  677. End If
  678. End With
  679. ' Populate the listview with the drive's statistics. Note that it doesn't matter
  680. ' which node is displaying the result view because both a list view and a listpad
  681. ' use ResultView.ListView to add their list items.
  682. DisplayDriveStats DriveName, ResultView.ListView.ListItems
  683. ' Store the index of the drive being displayed in ResultView.Tag. This allows the
  684. ' listpad button click handler to set the initial selection in its listbox to
  685. ' to the currently selected drive.
  686. ResultView.Tag = i
  687. Exit Sub
  688. ' Error Handler for this method
  689. ErrTrap_ResultViews_Initialize:
  690. DisplayError "ResultViews_Initialize"
  691. End Sub
  692. ' =============================================================================
  693. ' Method: DisplayDriveStats
  694. ' Type: Subroutine
  695. ' Description: Populates the list items with the drive's statistics
  696. ' Parameters: DriveBane Name of drive to show
  697. ' ListItems MMCListItems collection to populate
  698. '
  699. ' Output: None
  700. ' Notes: None
  701. ' =============================================================================
  702. '
  703. Private Sub DisplayDriveStats(DriveName As String, ListItems As MMCListItems)
  704. On Error GoTo ErrTrap_DispayDriveStats
  705. Dim drv As Scripting.Drive
  706. Dim fs As New Scripting.FileSystemObject
  707. ' Get the drive name and get a FileSystemObject Drive object so we can
  708. ' populate the listview with its properties.
  709. Set drv = fs.GetDrive(DriveName)
  710. ' Add each of the fields from the Drive object to the list items
  711. AddField ListItems, "DriveLetter", drv.DriveLetter
  712. AddField ListItems, "AvailableSpace", Format(drv.AvailableSpace, "#,##0 bytes")
  713. AddField ListItems, "DriveType", FormatDriveType(drv.DriveType)
  714. AddField ListItems, "FileSystem", drv.FileSystem
  715. AddField ListItems, "FreeSpace", Format(drv.FreeSpace, "#,##0 bytes")
  716. AddField ListItems, "IsReady", drv.IsReady
  717. AddField ListItems, "Path", drv.Path
  718. AddField ListItems, "SerialNumber", Hex$(drv.SerialNumber)
  719. AddField ListItems, "ShareName", drv.ShareName
  720. AddField ListItems, "TotalSize", Format(drv.TotalSize, "#,##0 bytes")
  721. AddField ListItems, "VolumeName", drv.VolumeName
  722. Exit Sub
  723. ' Error Handler for this method
  724. ErrTrap_DispayDriveStats:
  725. DisplayError "DispayDriveStats"
  726. End Sub
  727. ' =============================================================================
  728. ' Method: AddField
  729. ' Type: Subroutine
  730. ' Description: Adds a list item and its corresponding list subitems.
  731. ' Parameters: ListItems The MMCListItems collection being populated.
  732. ' Name Name of the Drive object field
  733. ' Value Value of the field
  734. ' Output: None
  735. ' Notes: None
  736. ' =============================================================================
  737. '
  738. Private Sub AddField(ListItems As MMCListItems, Name As String, Value As String)
  739. On Error GoTo ErrTrap_AddField
  740. Dim ListItem As MMCListItem
  741. Set ListItem = ListItems.Add(, Name, Name)
  742. ListItem.ListSubItems.Add 1, "Stat", Name
  743. ListItem.ListSubItems.Add 2, "Value", Value
  744. Exit Sub
  745. ' Error Handler for this method
  746. ErrTrap_AddField:
  747. DisplayError "AddField"
  748. End Sub
  749. ' =============================================================================
  750. ' Method: FormatDriveType
  751. ' Type: Function
  752. ' Description: Returns a string describing the type of drive.
  753. ' Parameters: DriveType A Scripting library enumeration describing the
  754. ' drive type.
  755. ' Output: None
  756. ' Notes: None
  757. ' =============================================================================
  758. '
  759. Private Function FormatDriveType(DriveType As Scripting.DriveTypeConst) As String
  760. On Error GoTo ErrTrap_FormatDriveType
  761. Select Case DriveType
  762. Case CDRom
  763. FormatDriveType = "CD ROM"
  764. Case Fixed
  765. FormatDriveType = "Fixed"
  766. Case RamDisk
  767. FormatDriveType = "Ram Disk"
  768. Case Remote
  769. FormatDriveType = "Remote"
  770. Case Removable
  771. FormatDriveType = "Removable"
  772. Case Unknown
  773. FormatDriveType = "Unknown"
  774. End Select
  775. Exit Function
  776. ' Error Handler for this method
  777. ErrTrap_FormatDriveType:
  778. DisplayError "FormatDriveType"
  779. End Function
  780. ' =============================================================================
  781. ' Method: DisplayError
  782. ' Type: Subroutine
  783. ' Description: A method to format and display a runtime error
  784. ' Parameters: szLocation A string identifying the source location
  785. ' (i.e. method name) where the error occurred
  786. ' Output: None
  787. ' Notes: The error will be displayed in a messagebox, with a format of
  788. '
  789. ' Method: SomeMethodName
  790. ' Source: MMCListSubItems
  791. ' Error: 2527h (9511)
  792. ' Description: There is already an item in the collection that has the specified key
  793. '
  794. ' =============================================================================
  795. '
  796. Private Sub DisplayError(szLocation As String)
  797. ConsoleMsgBox "Method:" & vbTab & vbTab & szLocation & vbCrLf _
  798. & "Source:" & vbTab & vbTab & Err.Source & vbCrLf _
  799. & "Error:" & vbTab & vbTab & Hex(Err.Number) & "h (" & CStr(Err.Number) & ")" & vbCrLf _
  800. & "Description:" & vbTab & Err.Description, _
  801. vbCritical, "DriveStats Extension Runtime Error"
  802. End Sub
  803. Private Sub Views_AddTaskMenuItems(ByVal View As SnapInLib.View, _
  804. ByVal Selection As SnapInLib.MMCClipboard, _
  805. ByVal ContextMenu As SnapInLib.ContextMenu, _
  806. InsertionAllowed As Boolean)
  807. On Error GoTo ErrTrap_Views_AddTaskMenuItems
  808. Dim DriveNames() As String
  809. Dim MenuItem As MMCMenu
  810. Dim i As Integer
  811. ' If this is not a single scope item then nothing to do
  812. If Selection.SelectionType <> siSingleScopeItem Then
  813. Exit Sub
  814. End If
  815. ' If it is not the "<Stats>" node we added under FileExplorer's "My Computer" node
  816. ' then nothing to do
  817. If Selection.ScopeItems(1).Name <> "MyComputerStats" Then
  818. Exit Sub
  819. End If
  820. ' Get the drive names array we stored in our MyComputerStats ScopeItem's
  821. ' Tag during ExtensionSnapIn_Expand.
  822. DriveNames = ScopeItems("MyComputerStats").Tag
  823. ' Clear out the children of mnuChooseTask and then add new ones for each drive
  824. mnuChooseTask.Children.Clear
  825. ' When adding the drives set Key to the drive name and set Tag to its index within
  826. ' the DriveNames array as we will need those if a drive is selected
  827. For i = LBound(DriveNames) To UBound(DriveNames)
  828. Set MenuItem = mnuChooseTask.Children.Add
  829. MenuItem.Caption = DriveNames(i)
  830. MenuItem.Key = DriveNames(i)
  831. MenuItem.Tag = i
  832. Next i
  833. ContextMenu.AddMenu mnuChooseDrive
  834. Exit Sub
  835. ' Error Handler for this method
  836. ErrTrap_Views_AddTaskMenuItems:
  837. DisplayError "Views_AddTaskMenuItems"
  838. End Sub
  839. Private Sub mnuChooseTask_Click(ByVal Index As Long, _
  840. ByVal Selection As SnapInLib.MMCClipboard)
  841. On Error GoTo ErrTrap_mnuChooseTask_Click
  842. ' Get the drive name from the click menu object's Key and get its index in DriveNames
  843. ' from the object's Tag
  844. With mnuChooseTask.Children(Index)
  845. ChangeDrive .Key, .Tag
  846. End With
  847. Exit Sub
  848. ' Error Handler for this method
  849. ErrTrap_mnuChooseTask_Click:
  850. DisplayError "mnuChooseTask_Click"
  851. End Sub