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.

400 lines
16 KiB

  1. VERSION 5.00
  2. Begin {B3E55942-FFD8-11D1-9788-44A620524153} ComDetect
  3. ClientHeight = 10020
  4. ClientLeft = 0
  5. ClientTop = 0
  6. ClientWidth = 11775
  7. _ExtentX = 20770
  8. _ExtentY = 17674
  9. m_iNextNodeNumber= 0
  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 = "mnuDetect"
  36. Tag = 0
  37. StatusBarText = ""
  38. BeginProperty Children {11517450-27FE-11D3-AA41-00104B880587}
  39. Persistence.MajorVersion= 0
  40. Persistence.MinorVersion= 12
  41. Count = 1
  42. KeysOnly = 0
  43. BeginProperty Item1 {91CC37D5-CE2B-11D1-B44D-7E92AF000000}
  44. Persistence.MajorVersion= 0
  45. Persistence.MinorVersion= 12
  46. Caption = "Is this file a COM server?"
  47. Visible = -1
  48. Checked = 0
  49. Enabled = -1
  50. Grayed = 0
  51. MenuBreak = 0
  52. MenuBarBreak = 0
  53. Default = 0
  54. Index = 1
  55. Name = "IsCOMServer"
  56. Tag = 0
  57. StatusBarText = "Examine the DLL to determine if it is a COM server"
  58. BeginProperty Children {11517450-27FE-11D3-AA41-00104B880587}
  59. Persistence.MajorVersion= 0
  60. Persistence.MinorVersion= 12
  61. Count = 0
  62. KeysOnly = 0
  63. EndProperty
  64. Key = "1"
  65. DISPID = 1001
  66. EndProperty
  67. EndProperty
  68. Key = "1"
  69. DISPID = 1000
  70. EndProperty
  71. EndProperty
  72. BeginProperty Toolbars {FFF9A8FA-06CB-11D2-9791-50C320524153}
  73. Persistence.MajorVersion= 0
  74. Persistence.MinorVersion= 12
  75. Count = 0
  76. KeysOnly = 0
  77. EndProperty
  78. BeginProperty ViewDefs {FFF9A8E1-06CB-11D2-9791-50C320524153}
  79. Persistence.MajorVersion= 0
  80. Persistence.MinorVersion= 12
  81. BeginProperty ListViews {FFF9A8FC-06CB-11D2-9791-50C320524153}
  82. Persistence.MajorVersion= 0
  83. Persistence.MinorVersion= 12
  84. Count = 0
  85. KeysOnly = 0
  86. EndProperty
  87. BeginProperty OCXViews {FFF9A8FF-06CB-11D2-9791-50C320524153}
  88. Persistence.MajorVersion= 0
  89. Persistence.MinorVersion= 12
  90. Count = 0
  91. KeysOnly = 0
  92. EndProperty
  93. BeginProperty URLViews {FFF9A902-06CB-11D2-9791-50C320524153}
  94. Persistence.MajorVersion= 0
  95. Persistence.MinorVersion= 12
  96. Count = 0
  97. KeysOnly = 0
  98. EndProperty
  99. BeginProperty TaskpadViews {FFF9A904-06CB-11D2-9791-50C320524153}
  100. Persistence.MajorVersion= 0
  101. Persistence.MinorVersion= 12
  102. Count = 0
  103. KeysOnly = 0
  104. EndProperty
  105. EndProperty
  106. BeginProperty DataFormats {91FE14C5-7370-11D2-97D8-00104B880587}
  107. Persistence.MajorVersion= 0
  108. Persistence.MinorVersion= 12
  109. Count = 0
  110. KeysOnly = 0
  111. EndProperty
  112. BeginProperty SnapInDef {FFF9A8E4-06CB-11D2-9791-50C320524153}
  113. Persistence.MajorVersion= 0
  114. Persistence.MinorVersion= 12
  115. Name = "ComDetect"
  116. NodeTypeName = "SnapIn1"
  117. NodeTypeGUID = "{D42F4544-CD95-11d2-97ED-00104B880587}"
  118. DisplayName = "ComDetect"
  119. Type = 1
  120. HelpFile = ""
  121. LinkedTopics = ""
  122. Description = "Detects whether a DLL is also a COM server"
  123. Provider = "Microsoft Corporation"
  124. Version = "1.0"
  125. SmallFolders = ""
  126. SmallFoldersOpen= ""
  127. LargeFolders = ""
  128. Icon = "ComDetect.dsx":0000
  129. Watermark = "ComDetect.dsx":005E
  130. Header = "ComDetect.dsx":00BC
  131. Palette = "ComDetect.dsx":011A
  132. StretchWatermark= 0
  133. StaticFolder = 0
  134. DefaultView = ""
  135. Extensible = 0
  136. BeginProperty ViewDefs {FFF9A8E1-06CB-11D2-9791-50C320524153}
  137. Persistence.MajorVersion= 0
  138. Persistence.MinorVersion= 12
  139. BeginProperty ListViews {FFF9A8FC-06CB-11D2-9791-50C320524153}
  140. Persistence.MajorVersion= 0
  141. Persistence.MinorVersion= 12
  142. Count = 0
  143. KeysOnly = 1
  144. EndProperty
  145. BeginProperty OCXViews {FFF9A8FF-06CB-11D2-9791-50C320524153}
  146. Persistence.MajorVersion= 0
  147. Persistence.MinorVersion= 12
  148. Count = 0
  149. KeysOnly = 1
  150. EndProperty
  151. BeginProperty URLViews {FFF9A902-06CB-11D2-9791-50C320524153}
  152. Persistence.MajorVersion= 0
  153. Persistence.MinorVersion= 12
  154. Count = 0
  155. KeysOnly = 1
  156. EndProperty
  157. BeginProperty TaskpadViews {FFF9A904-06CB-11D2-9791-50C320524153}
  158. Persistence.MajorVersion= 0
  159. Persistence.MinorVersion= 12
  160. Count = 0
  161. KeysOnly = 1
  162. EndProperty
  163. EndProperty
  164. BeginProperty Children {FFF9A8F4-06CB-11D2-9791-50C320524153}
  165. Persistence.MajorVersion= 0
  166. Persistence.MinorVersion= 12
  167. Count = 0
  168. KeysOnly = 0
  169. EndProperty
  170. IID = "{23F18716-2FB0-4E93-94D5-B50CFDC311B4}"
  171. Preload = 0
  172. EndProperty
  173. BeginProperty ExtensionDefs {FFF9A8E6-06CB-11D2-9791-50C320524153}
  174. Persistence.MajorVersion= 0
  175. Persistence.MinorVersion= 12
  176. ExtendsNewMenu = 0
  177. ExtendsTaskMenu = 0
  178. ExtendsTopMenu = 0
  179. ExtendsViewMenu = 0
  180. ExtendsPropertyPages= 0
  181. ExtendsToolbar = 0
  182. ExtendsNameSpace= 0
  183. BeginProperty ExtendedSnapIns {BDA4B9D1-0872-11D2-9791-50C320524153}
  184. Persistence.MajorVersion= 0
  185. Persistence.MinorVersion= 12
  186. Count = 1
  187. KeysOnly = 0
  188. BeginProperty Item1 {FFF9A8E8-06CB-11D2-9791-50C320524153}
  189. Persistence.MajorVersion= 0
  190. Persistence.MinorVersion= 12
  191. Name = ""
  192. Index = 1
  193. Key = "{D2B294B2-9F64-11d2-97E1-00104B880587}"
  194. CLSID = "{D2B294B2-9F64-11d2-97E1-00104B880587}"
  195. DisplayName = "lvExporerFiles"
  196. Dynamic = -1
  197. ExtendsNameSpace= 0
  198. ExtendsNewMenu = 0
  199. ExtendsTaskMenu = -1
  200. ExtendsPropertyPages= 0
  201. ExtendsToolbar = 0
  202. ExtendsTaskpad = 0
  203. EndProperty
  204. EndProperty
  205. EndProperty
  206. BeginProperty AutoCreateNodes {FFF9A8F4-06CB-11D2-9791-50C320524153}
  207. Persistence.MajorVersion= 0
  208. Persistence.MinorVersion= 12
  209. Count = 0
  210. KeysOnly = 0
  211. EndProperty
  212. BeginProperty OtherNodes {FFF9A8F4-06CB-11D2-9791-50C320524153}
  213. Persistence.MajorVersion= 0
  214. Persistence.MinorVersion= 12
  215. Count = 0
  216. KeysOnly = 0
  217. EndProperty
  218. TypeinfoCookie = 8
  219. ProjectName = "ComDetectProj"
  220. End
  221. Attribute VB_Name = "ComDetect"
  222. Attribute VB_GlobalNameSpace = False
  223. Attribute VB_Creatable = True
  224. Attribute VB_PredeclaredId = False
  225. Attribute VB_Exposed = True
  226. Option Explicit
  227. ' ===========================================================================
  228. ' | THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF |
  229. ' | ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO |
  230. ' | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A |
  231. ' | PARTICULAR PURPOSE. |
  232. ' | Copyright (c) 1998-1999 Microsoft Corporation |
  233. ' ===========================================================================
  234. ' =============================================================================
  235. ' File: ComDetect.dsr
  236. ' Project: ComDetectProj
  237. ' Type: SnapIn Designer
  238. ' =============================================================================
  239. ' Declare Windows API functions needed to check for DllRegisterServer export
  240. Private Declare Function LoadLibrary Lib "kernel32.dll" Alias "LoadLibraryA" (ByVal Path As String) As Long
  241. Private Declare Function GetProcAddress Lib "kernel32.dll" (ByVal hModule As Long, ByVal ProcName As String) As Long
  242. Private Declare Function FreeLibrary Lib "kernel32.dll" (ByVal hModule As Long)
  243. ' =============================================================================
  244. ' Method: ExtensionSnapIn_AddTaskMenuItems
  245. ' Type: Event
  246. ' Description: Fired when a context menu is about to be displayed to give the
  247. ' extension snap-in the opportunity to add items to MMC's "Task"
  248. ' sub-menu.
  249. '
  250. ' Parameters: DataObjects An MMCDataObject collection that contains the
  251. ' current selection. The extension snap-in must
  252. ' interpret the data exported by the extended
  253. ' snap-ins (in this case FileExplorer exports the
  254. ' data)
  255. ' ContextMenu A ContextMenu object that allows adding the
  256. ' snap-in's menus.
  257. ' Output: None
  258. ' Notes: Adds mnuDetect containing the "Is this file a COM server..."
  259. ' item.
  260. ' =============================================================================
  261. '
  262. Private Sub ExtensionSnapIn_AddTaskMenuItems(ByVal DataObjects As SnapInLib.IMMCDataObjects, _
  263. ByVal ContextMenu As SnapInLib.IContextMenu)
  264. On Error GoTo ErrTrap_ExtensionSnapIn_AddTaskMenuItems
  265. Dim strPath As String
  266. Dim varPath As Variant
  267. ' If there is anything other than a single data object then we ignore it
  268. ' as FileExplorer exports one MMCDataObject with the format "Path" when the
  269. ' selected item is a single file.
  270. If DataObjects.Count <> 1 Then
  271. Exit Sub
  272. End If
  273. ' Extract the file's path from the data object. Note that we cannot
  274. ' just assign the Variant returned from MMCDataObject.GetData to a string
  275. ' because it will contain an array of bytes terminated by multiple zero
  276. ' bytes. This is due to the way the runtime must convert the exported string
  277. ' from FileExplorer to a raw memory block of bytes that can be imported by
  278. ' other snap-ins. If we did the straight assignment and then concatenated
  279. ' another string to the path, certain functions (e.g.MsgBox) would truncate
  280. ' the concatenated string due to the embedded zero bytes.
  281. ' To solve this problem we use the designer's FormatData method that can
  282. ' convert from a byte array to different data types.
  283. varPath = DataObjects(1).GetData("Path")
  284. strPath = FormatData(varPath, 1, siString)
  285. ' Set the IsComServer menu item's tag to the DLL's path. If the menu item
  286. ' is clicked, the event handler will get the path from the tag.
  287. IsCOMServer.Tag = strPath
  288. ' Add mnuDetect containing the "Is this file a COM server..." item.
  289. ContextMenu.AddMenu mnuDetect
  290. Exit Sub
  291. ' Error Handler for this method
  292. ErrTrap_ExtensionSnapIn_AddTaskMenuItems:
  293. DisplayError "ExtensionSnapIn_AddTaskMenuItems"
  294. End Sub
  295. ' =============================================================================
  296. ' Method: IsCOMServer_Click
  297. ' Type: Event
  298. ' Description: Fired when the "Is this file a COM server..." context menu item
  299. ' is selected.
  300. '
  301. ' Parameters: Index This will always be 1 as we are directly handling
  302. ' the event on the individual menu item rather than
  303. ' the event on its parent.
  304. ' Selection A reference to an MMCClipboard object that is
  305. ' holding a reference to the currently selected
  306. ' item(s). Note that even though the selection is
  307. ' held in an MMCClipboard object, its ScopeItems and
  308. ' ListItems collection will always be empty in an
  309. ' extension snap-in because the selected items(s)
  310. ' belong to the extended snap-in (FileExplorer in
  311. ' this case). The extension snap-in must interpret
  312. ' the exported data in MMCClipboard.DataObjects.
  313. ' Output: None
  314. ' Notes: Gets the path from the MMCMenu object's Tag property and uses
  315. ' Win32 API calls to determine if the file exports
  316. ' "DllRegisterServer".
  317. ' =============================================================================
  318. '
  319. Private Sub IsCOMServer_Click(ByVal Index As Long, ByVal Selection As SnapInLib.IMMCClipboard)
  320. On Error GoTo ErrTrap_ExtensionSnapIn_IsCOMServer_Click
  321. Dim hModule As Long
  322. Dim ProcAddr As Long
  323. Dim IsOrNot As String
  324. hModule = LoadLibrary(IsCOMServer.Tag)
  325. If hModule <> 0 Then
  326. ProcAddr = GetProcAddress(hModule, "DllRegisterServer")
  327. If ProcAddr <> 0 Then
  328. IsOrNot = " is "
  329. Else
  330. IsOrNot = " is not "
  331. End If
  332. MsgBox IsCOMServer.Tag & IsOrNot & "a COM server.", _
  333. vbOKOnly, "ComDetect Extension"
  334. FreeLibrary hModule
  335. Else
  336. MsgBox "Error loading " & IsCOMServer.Tag, vbOKOnly, "ComDetect"
  337. End If
  338. Exit Sub
  339. ' Error Handler for this method
  340. ErrTrap_ExtensionSnapIn_IsCOMServer_Click:
  341. DisplayError "ExtensionSnapIn_IsCOMServer_Click"
  342. End Sub
  343. ' =============================================================================
  344. ' Method: DisplayError
  345. ' Type: Subroutine
  346. ' Description: A method to format and display a runtime error
  347. ' Parameters: szLocation A string identifying the source location
  348. ' (i.e. method name) where the error occurred
  349. ' Output: None
  350. ' Notes: The error will be displayed in a messagebox formatted as the
  351. ' following sample:
  352. '
  353. ' Method: SomeMethodName
  354. ' Source: MMCListSubItems
  355. ' Error: 2527h (9511)
  356. ' Description: There is already an item in the collection that has the specified key
  357. '
  358. ' =============================================================================
  359. '
  360. Private Sub DisplayError(szLocation As String)
  361. ' Note that as an extension snap-in we do not have access to the
  362. ' ConsoleMsgBox method so we need to use a VB message box.
  363. MsgBox "Method:" & vbTab & vbTab & szLocation & vbCrLf _
  364. & "Source:" & vbTab & vbTab & Err.Source & vbCrLf _
  365. & "Error:" & vbTab & vbTab & Hex(Err.Number) & "h (" & CStr(Err.Number) & ")" & vbCrLf _
  366. & "Description:" & vbTab & Err.Description, _
  367. vbCritical, "ComDetect Runtime Error"
  368. End Sub