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

VERSION 5.00
Begin {B3E55942-FFD8-11D1-9788-44A620524153} ComDetect
ClientHeight = 10020
ClientLeft = 0
ClientTop = 0
ClientWidth = 11775
_ExtentX = 20770
_ExtentY = 17674
m_iNextNodeNumber= 0
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
BeginProperty ImageLists {FFF9A8F6-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
BeginProperty Menus {11517450-27FE-11D3-AA41-00104B880587}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 1
KeysOnly = 0
BeginProperty Item1 {91CC37D5-CE2B-11D1-B44D-7E92AF000000}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Caption = "Menu1"
Visible = -1
Checked = 0
Enabled = -1
Grayed = 0
MenuBreak = 0
MenuBarBreak = 0
Default = 0
Index = 1
Name = "mnuDetect"
Tag = 0
StatusBarText = ""
BeginProperty Children {11517450-27FE-11D3-AA41-00104B880587}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 1
KeysOnly = 0
BeginProperty Item1 {91CC37D5-CE2B-11D1-B44D-7E92AF000000}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Caption = "Is this file a COM server?"
Visible = -1
Checked = 0
Enabled = -1
Grayed = 0
MenuBreak = 0
MenuBarBreak = 0
Default = 0
Index = 1
Name = "IsCOMServer"
Tag = 0
StatusBarText = "Examine the DLL to determine if it is a COM server"
BeginProperty Children {11517450-27FE-11D3-AA41-00104B880587}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
Key = "1"
DISPID = 1001
EndProperty
EndProperty
Key = "1"
DISPID = 1000
EndProperty
EndProperty
BeginProperty Toolbars {FFF9A8FA-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
BeginProperty ViewDefs {FFF9A8E1-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
BeginProperty ListViews {FFF9A8FC-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
BeginProperty OCXViews {FFF9A8FF-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
BeginProperty URLViews {FFF9A902-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
BeginProperty TaskpadViews {FFF9A904-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
EndProperty
BeginProperty DataFormats {91FE14C5-7370-11D2-97D8-00104B880587}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
BeginProperty SnapInDef {FFF9A8E4-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Name = "ComDetect"
NodeTypeName = "SnapIn1"
NodeTypeGUID = "{D42F4544-CD95-11d2-97ED-00104B880587}"
DisplayName = "ComDetect"
Type = 1
HelpFile = ""
LinkedTopics = ""
Description = "Detects whether a DLL is also a COM server"
Provider = "Microsoft Corporation"
Version = "1.0"
SmallFolders = ""
SmallFoldersOpen= ""
LargeFolders = ""
Icon = "ComDetect.dsx":0000
Watermark = "ComDetect.dsx":005E
Header = "ComDetect.dsx":00BC
Palette = "ComDetect.dsx":011A
StretchWatermark= 0
StaticFolder = 0
DefaultView = ""
Extensible = 0
BeginProperty ViewDefs {FFF9A8E1-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
BeginProperty ListViews {FFF9A8FC-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 1
EndProperty
BeginProperty OCXViews {FFF9A8FF-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 1
EndProperty
BeginProperty URLViews {FFF9A902-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 1
EndProperty
BeginProperty TaskpadViews {FFF9A904-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 1
EndProperty
EndProperty
BeginProperty Children {FFF9A8F4-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
IID = "{23F18716-2FB0-4E93-94D5-B50CFDC311B4}"
Preload = 0
EndProperty
BeginProperty ExtensionDefs {FFF9A8E6-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
ExtendsNewMenu = 0
ExtendsTaskMenu = 0
ExtendsTopMenu = 0
ExtendsViewMenu = 0
ExtendsPropertyPages= 0
ExtendsToolbar = 0
ExtendsNameSpace= 0
BeginProperty ExtendedSnapIns {BDA4B9D1-0872-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 1
KeysOnly = 0
BeginProperty Item1 {FFF9A8E8-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Name = ""
Index = 1
Key = "{D2B294B2-9F64-11d2-97E1-00104B880587}"
CLSID = "{D2B294B2-9F64-11d2-97E1-00104B880587}"
DisplayName = "lvExporerFiles"
Dynamic = -1
ExtendsNameSpace= 0
ExtendsNewMenu = 0
ExtendsTaskMenu = -1
ExtendsPropertyPages= 0
ExtendsToolbar = 0
ExtendsTaskpad = 0
EndProperty
EndProperty
EndProperty
BeginProperty AutoCreateNodes {FFF9A8F4-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
BeginProperty OtherNodes {FFF9A8F4-06CB-11D2-9791-50C320524153}
Persistence.MajorVersion= 0
Persistence.MinorVersion= 12
Count = 0
KeysOnly = 0
EndProperty
TypeinfoCookie = 8
ProjectName = "ComDetectProj"
End
Attribute VB_Name = "ComDetect"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
' ===========================================================================
' | THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF |
' | ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO |
' | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A |
' | PARTICULAR PURPOSE. |
' | Copyright (c) 1998-1999 Microsoft Corporation |
' ===========================================================================
' =============================================================================
' File: ComDetect.dsr
' Project: ComDetectProj
' Type: SnapIn Designer
' =============================================================================
' Declare Windows API functions needed to check for DllRegisterServer export
Private Declare Function LoadLibrary Lib "kernel32.dll" Alias "LoadLibraryA" (ByVal Path As String) As Long
Private Declare Function GetProcAddress Lib "kernel32.dll" (ByVal hModule As Long, ByVal ProcName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32.dll" (ByVal hModule As Long)
' =============================================================================
' Method: ExtensionSnapIn_AddTaskMenuItems
' Type: Event
' Description: Fired when a context menu is about to be displayed to give the
' extension snap-in the opportunity to add items to MMC's "Task"
' sub-menu.
'
' Parameters: DataObjects An MMCDataObject collection that contains the
' current selection. The extension snap-in must
' interpret the data exported by the extended
' snap-ins (in this case FileExplorer exports the
' data)
' ContextMenu A ContextMenu object that allows adding the
' snap-in's menus.
' Output: None
' Notes: Adds mnuDetect containing the "Is this file a COM server..."
' item.
' =============================================================================
'
Private Sub ExtensionSnapIn_AddTaskMenuItems(ByVal DataObjects As SnapInLib.IMMCDataObjects, _
ByVal ContextMenu As SnapInLib.IContextMenu)
On Error GoTo ErrTrap_ExtensionSnapIn_AddTaskMenuItems
Dim strPath As String
Dim varPath As Variant
' If there is anything other than a single data object then we ignore it
' as FileExplorer exports one MMCDataObject with the format "Path" when the
' selected item is a single file.
If DataObjects.Count <> 1 Then
Exit Sub
End If
' Extract the file's path from the data object. Note that we cannot
' just assign the Variant returned from MMCDataObject.GetData to a string
' because it will contain an array of bytes terminated by multiple zero
' bytes. This is due to the way the runtime must convert the exported string
' from FileExplorer to a raw memory block of bytes that can be imported by
' other snap-ins. If we did the straight assignment and then concatenated
' another string to the path, certain functions (e.g.MsgBox) would truncate
' the concatenated string due to the embedded zero bytes.
' To solve this problem we use the designer's FormatData method that can
' convert from a byte array to different data types.
varPath = DataObjects(1).GetData("Path")
strPath = FormatData(varPath, 1, siString)
' Set the IsComServer menu item's tag to the DLL's path. If the menu item
' is clicked, the event handler will get the path from the tag.
IsCOMServer.Tag = strPath
' Add mnuDetect containing the "Is this file a COM server..." item.
ContextMenu.AddMenu mnuDetect
Exit Sub
' Error Handler for this method
ErrTrap_ExtensionSnapIn_AddTaskMenuItems:
DisplayError "ExtensionSnapIn_AddTaskMenuItems"
End Sub
' =============================================================================
' Method: IsCOMServer_Click
' Type: Event
' Description: Fired when the "Is this file a COM server..." context menu item
' is selected.
'
' Parameters: Index This will always be 1 as we are directly handling
' the event on the individual menu item rather than
' the event on its parent.
' Selection A reference to an MMCClipboard object that is
' holding a reference to the currently selected
' item(s). Note that even though the selection is
' held in an MMCClipboard object, its ScopeItems and
' ListItems collection will always be empty in an
' extension snap-in because the selected items(s)
' belong to the extended snap-in (FileExplorer in
' this case). The extension snap-in must interpret
' the exported data in MMCClipboard.DataObjects.
' Output: None
' Notes: Gets the path from the MMCMenu object's Tag property and uses
' Win32 API calls to determine if the file exports
' "DllRegisterServer".
' =============================================================================
'
Private Sub IsCOMServer_Click(ByVal Index As Long, ByVal Selection As SnapInLib.IMMCClipboard)
On Error GoTo ErrTrap_ExtensionSnapIn_IsCOMServer_Click
Dim hModule As Long
Dim ProcAddr As Long
Dim IsOrNot As String
hModule = LoadLibrary(IsCOMServer.Tag)
If hModule <> 0 Then
ProcAddr = GetProcAddress(hModule, "DllRegisterServer")
If ProcAddr <> 0 Then
IsOrNot = " is "
Else
IsOrNot = " is not "
End If
MsgBox IsCOMServer.Tag & IsOrNot & "a COM server.", _
vbOKOnly, "ComDetect Extension"
FreeLibrary hModule
Else
MsgBox "Error loading " & IsCOMServer.Tag, vbOKOnly, "ComDetect"
End If
Exit Sub
' Error Handler for this method
ErrTrap_ExtensionSnapIn_IsCOMServer_Click:
DisplayError "ExtensionSnapIn_IsCOMServer_Click"
End Sub
' =============================================================================
' Method: DisplayError
' Type: Subroutine
' Description: A method to format and display a runtime error
' Parameters: szLocation A string identifying the source location
' (i.e. method name) where the error occurred
' Output: None
' Notes: The error will be displayed in a messagebox formatted as the
' following sample:
'
' Method: SomeMethodName
' Source: MMCListSubItems
' Error: 2527h (9511)
' Description: There is already an item in the collection that has the specified key
'
' =============================================================================
'
Private Sub DisplayError(szLocation As String)
' Note that as an extension snap-in we do not have access to the
' ConsoleMsgBox method so we need to use a VB message box.
MsgBox "Method:" & vbTab & vbTab & szLocation & vbCrLf _
& "Source:" & vbTab & vbTab & Err.Source & vbCrLf _
& "Error:" & vbTab & vbTab & Hex(Err.Number) & "h (" & CStr(Err.Number) & ")" & vbCrLf _
& "Description:" & vbTab & Err.Description, _
vbCritical, "ComDetect Runtime Error"
End Sub