Snap-in Designer Samples

[This is preliminary documentation and subject to change.]

© 1999 Microsoft Corporation. All rights reserved.

Built on Wednesday, October 20, 1999


Software Requirements

  • Microsoft Windows NT® Workstation or Server version 4.0 with Service Pack 3 or later, or Microsoft Windows® 2000 beta 3 or later, or Microsoft Windows 95 or Windows 98.
  • Microsoft Visual Basic® version 6.0 (no specific service pack required)
  • MMC Snap-in Designer for Visual Basic beta 2
  • Microsoft Management Console version 1.1 or later


Compiling the Samples

To compile the sample snap-ins

  1. Start Visual Basic 6.0.
  2. On the File menu, click Open Project.
  3. In the Open Project dialog box, click MMCDesignerSamples.vbg. This is a project group file that contains all of the sample projects.
  4. Click Open.
  5. On the File menu, click Make Project Group….
  6. In the dialog box, click Build to start compiling.


Running the Samples

To run the sample snap-ins

  1. Start MMC.
  2. On the Console menu, click Add/Remove Snap-in.
  4. Click the Standalone tab, then click Add.
  5. In the Add a Standalone Snap-in dialog box, click File Explorer in the Available Standalone Snap-ins list.
  6. Click Add.
  7. Answer the configuration wizard questions.
  8. Click Close.
  9. Click OK.

This procedure loads the FileExplorer sample into the console. The other samples are all extensions of FileExplorer and they will be loaded by MMC as needed.


Sample Functionality

The FileExplorer snap-in mimics the functionality of Windows Explorer in Microsoft Windows NT, Windows 2000, and Windows 9x. It uses almost all the features of MMC in order to demonstrate their implementation in a Visual Basic snap-in. A configuration wizard asks whether to display network drives and whether to allow rename and delete for folders and files. If you save your console, FileExplorer will remember your configuration settings when it is reloaded.

FileExplorer is a dual-mode snap-in. It can be added to the console as a stand-alone snap-in, or in Windows 2000, it will appear as a namespace extension of Computer Management\System Tools. Its functionality is identical in both cases.

The static node has both a taskpad and a list view. If you are running MMC 1.1 and your console has the option "Show taskpad views by default" selected, or you are running MMC 1.2, then the default result view for the static node is the taskpad. If that option is not selected, then the default result view is a list view showing the Desktop node.

Expanding the Desktop node reveals a My Computer node, and finally a list of the drives currently available on your computer. This includes all removable media, local hard disk drives, CD-ROMs, and network drives if you specified that in the configuration wizard.

In addition to the My Computer node, the desktop also contains the shell folders for Internet Explorer, Network Neighborhood, Recycle Bin, and My Briefcase. The Internet Explorer node uses a URL result view as a simple browser. To set the URL, display properties for the node. The New submenu on the node's context menu has a "URL…" item that also displays the property sheet. Clicking the MMC Home Page task on the static node taskpad selects the Internet Explorer node and sets the URL to the MMC home page on microsoft.com. The other shell folder nodes are only for demonstration purposes and they do not display anything in the result pane.

The final node under My Computer is About FileExplorer. This node displays an OCX view in the result pane with some informational text and a button that invokes the same configuration wizard displayed when FileExplorer is added to a console. This demonstrates using the MMCPropertySheetProvider object from within an ActiveX control. Clicking the About task on the static node taskpad selects this node.

As in Windows Explorer, as you select specific drives or folders in the scope pane, the result pane is populated with a list of subfolders and files. When the view mode is set to Detail or Filtered, statistics for each file are displayed as well. The list view supports multiple selection. It also supports sorting on name, date, size, and attributes by clicking the column headers.

In Filtered view mode (available only on MMC 1.2), the name column supports some primitive filtering by name or by extension (*.<ext> or <name>.*). Click the filter button (in the lower-right corner of the column header) to display a pop-up menu that allows choosing which type of filtering should be used.

Rename and delete are supported for files and folders depending on the options specified in the configuration wizard.

Drag/drop and cut/copy/paste are also supported based on the configuration options. Targets can be folders or drives. The source can be any combination of folders and files.

Print is supported for files and, unlike Windows Explorer, it will handle multiple selection. Printing is done by invoking the system command processor's print command (for example, typing print <file name> at the command prompt).

Properties are supported for folders and files and are read-only (that is, you can't change a file attribute in the property page). Multiple selection is supported for property pages.

In addition to the console verbs described in the preceding paragraphs, FileExplorer has a number of custom actions that can be invoked from the context menu, a menu button, or a toolbar. These actions are as follows:

  • Run can be used to launch applications. This can be done either by double-clicking a file name in the result pane or by highlighting the file and clicking the Run toolbar button, the context menu item, or the menu button item. If the selected file is an application, it is launched immediately. If it is another type of file and the extension has an application associated with it, that application is launched with the file. Run also supports multiple selection.
  • RunAs is similar to Run except that it brings up a dialog box with an edit control. Inside the edit control is the fully qualified path name of the selected file. The user can modify this command line by, for example, preceding the file path with "Notepad" (Notepad c:\Temp\Abc.xyz). In this way, a file can be launched using any application.
  • New Folder creates a new folder underneath the currently selected folder or drive.
  • On the Explorer menu button, there is a Configuration item that runs the same configuration wizard that is displayed when FileExplorer is added to the console.

FileExplorer also has a number of extension snap-ins that add functionality and demonstrate all the different extension features of MMC. These extensions are as follows:

  • ComDetect is a very simple context menu extension that adds an item to the All Tasks submenu of MMC's context menu when a single DLL file is selected. It displays a message box saying whether the DLL is also a COM server. It determines this by using the Win32® API functions LoadLibrary and GetProcAddress to determine if the DLL exports the required DllRegisterServer function for in-process COM servers. Some DLLs might not load because some of its required additional DLLs may not be present.

    ComDetect is a dynamic extension and FileExplorer loads it only when a DLL file is selected.

  • DriveStats is a dynamic namespace extension that adds a scope item underneath every drive. The scope item appears with the name <Stats> and has a list view showing the drive's properties.

    DriveStats also adds a <Stats> node under the My Computer node that displays a listpad showing the properties of the C drive. Clicking the listpad button displays a dialog box that allows selecting a different drive.

  • FileViewer is a complex extension that extends FileExplorer's toolbar, menu buttons, property pages, taskpad, and context menus. FileExplorer loads it as a required extension.

    FileViewer adds a toolbar button, a menu button, and an All Tasks context menu item that allow viewing the context of a file. FileViewer displays the file within a multiline edit control, so it is best suited for text files. It also adds a property page to the file's property sheet that displays the contents of the file. It supports multiple selection for property pages.

    In an action unrelated to its name, FileViewer adds a property page to folder properties that displays some statistics about the folder. It is best to invoke this action on small folders that in turn reside within small folders because the statistics can take a while to gather.

    FileViewer also adds an "About FileViewer" task to FileExplorer's static node taskpad.

The following diagram illustrates the various user interface objects added by FileExplorer and its extensions:


FileExplorer -- Design-Time Objects

Platform SDK: Management Console

FileExplorer — Design-Time Objects

[This is preliminary documentation and subject to change.]

This section provides descriptions of the objects defined by FileExplorer in the snap-in designer.


Auto-Create Nodes

Auto-create nodes are defined using the snap-in designer in the Visual Basic IDE (integrated development environment). The nodes are customized using property pages. The snap-in designer takes this information and automatically creates each of these nodes at run time. Each auto-create node is represented by an entry in the tree view in MMC's scope pane. Each auto-create node is also accessible during run time by a corresponding ScopeItem object.

Name | Static Node
Description | This is the snap-in's static node and is the only one that is required for a primary snap-in. It is listed in the designer window with the name Static Node, but it will appear in MMC as File Explorer, as the direct child of the Console Root or of Computer Management\System Tools in Windows 2000.
Result Views | lvExplorerTop, ovAbout, uvMMCHome, StaticNodeTaskpad
Image Lists | imgSmallFolders, imgSmallOpenFolders, imgLargeFolders

Name | Desktop
Description | This node is defined as a child of the static node, and will appear directly under File Explorer when that node is expanded. Nodes are expanded either by clicking the node in the scope pane or by clicking the plus (+) sign to the left of it.
Result Views | lvExplorerFiles
Image Lists | imgSmallFolders, imgSmallOpenFolders, imgLargeFolders

Name | MyComputer
Description | This is a child of the Desktop node and will appear when the Desktop is expanded.
Result Views | lvExplorerMain
Image Lists | imgSmallFolders, imgSmallOpenFolders, imgLargeFolders

Name | Internet Explorer, NetworkNeighborhood, RecycleBin, MyBriefcase
Description | These are special shell folders that are also children of the Desktop node. They are added for the purpose of example but only Internet Explorer displays a result view.
Result Views | Programmatically defined URL view. Display properties for the node to select the URL. Context menu also has "URL…" on New submenu that displays the property sheet.
Image Lists | None

Name | About
Description | This is a child of the Desktop node and will appear when the Desktop is expanded. It displays an OCX view with informational text and a button that invokes the same configuration wizard displayed when FileExplorer is added to a console.
Result Views | ovAbout
Image Lists | None


Other Nodes

Other predefined nodes are essentially templates for ScopeItem objects. They are not automatically created by the runtime, but can be used by the snap-in to dynamically create new nodes using all of the template's properties during the snap-in's execution. They are defined and configured just like auto-create nodes.

Name | Directory
Description | Used to create nodes for disk drives and folders.
Result Views | lvExplorerFiles
Image Lists | imgSmallFolders, imgSmallOpenFolders, imgLargeFolders

Name | ExtensionRoot
Description | The same as the static node but used as the root when File Explorer is created as an extension of Computer Managerment\System Tools in Windows 2000.
Result Views | lvExplorerTop, ovAbout, uvMMCHome, StaticNodeTaskpad, FAQListpad
Image Lists | imgSmallFolders, imgSmallOpenFolders, imgLargeFolders


List Views

FileExplorer defines the following list views:

Name | lvExplorerTop
Description | This list view is associated with the static node. It only displays the Desktop folder.
Default View Mode | Report
Image Lists | imgSmallFolders, imgLargeFolders
Column Headers | Name

Name | lvExplorerMain
Description | This list view is associated with the MyComputer auto-create node. It is defined to present drive-centric statistics.
Default View Mode | Report
Image Lists | imgSmallFolders, imgLargeFolders
Column Headers | Name, Type, Total Size, Free Space

Name | lvExplorerFiles
Description | This list view is associated with the Directory predefined node. It is used for displaying drives, folders, and files. It is also associated with those auto-create nodes that represent special folders that contain files, such as the Desktop and RecycleBin nodes.
Default View Mode | Report
ImageLists | imgSmallFolders, imgLargeFolders
Column Headers | Name, Size, Date Modified, Attributes


OCX Views

FileExplorer defines the following OCX view:

Name | ovAbout
Description | The result view for the About node under Desktop. Implemented by the user control AboutCtl that is part of the FileExplorer project. Contains a button that displays the same configuration wizard used when FileExplorer is added to the console.
ProgID | FileExplorerSample.AboutCtl


Taskpads

FileExplorer defines the following taskpad:

Name | StaticNodeTaskpad
Description | Displayed for the static node when the console's "Show taskpad views by default" option is selected.
Type | Default taskpad
Tasks | How to Use the File Explorer (URL: HTML page contained in custom resource) Start File Explorer (Notify: changes result view to lvExplorerTop) MMC Home Page (Notify: selects Internet Explorer and displays URL for MMC home page on microsoft.com) About (Notify: selects About node under Desktop)


Toolbars and Menu Buttons

Toolbars are not directly associated with any particular node or result view at design time. Toolbars are defined and configured in the designer window and are attached to the control bar for a particular view at run time. The control bar is the controlling entity for all the toolbars and menu buttons of a snap-in. Toolbars can be attached to and detached from the control bar at various times during the life of a snap-in. Because each toolbar is defined at design time, individual buttons on any toolbar can be accessed by code. It is therefore a simple matter to enable, disable, make visible, or hide any button(s) in response to any event as appropriate.

Menu buttons are defined by creating a toolbar in which all buttons have the DropDown style. Toolbar button styles must be consistent because MMC does not allow mixing toolbar buttons and menu buttons. This means that if one button in a toolbar has the DropDown style then they all must have that style.

FileExplorer defines the following toolbar and menu button:

Name | tbrFileMgr
Description | Defines FileExplorer's only toolbar.
ImageList | imgButtons
Buttons | Add (Adds a new folder) Run (Runs the selected file) RunAs (Prompts for a command line to run the selected file)

Name | tbrMenuButton
Description | Defines FileExplorer's only MenuButton
Buttons | Explorer (ButtonMenus: Add, Run, RunAs, Configuration)


Menus

Menus, like toolbars, are not directly associated with any particular node or result view at design time. Menus are defined and configured in the designer window, and are attached to the console's context menus at run time. For every insertion point where the snap-in needs to insert menu items, a menu must be defined. That menu functions like a pop-up menu on a Visual Basic form, that is, it is not displayed but its contained items are.

FileExplorer defines the following menus:

Name | mnuContext
Description | Added to the top of the console's context menu for single and multiple file selections.
Items | mnuRun (Runs the selected file) mnuRunAs (Prompts for a command line to run the selected file)

Name | mnuNew
Description | Added to the New submenu of the console's context menu for folders and drives.
Items | mnuNewFolder (Creates a new folder under the selected drive or folder)

Name | mnuNewURL
Description | Added to the New submenu of the console's context menu for the Internet Explorer node.
Items | mnuURL (Displays property sheet for node that allows specifying URL)

Name | mnuFilterOp
Description | Displayed in response to a filter button click when the lvExplorerFiles list view is in filtered mode (MMC 1.2 only).
Items | mnuFilterByName (Filter displayed files using <filter value>.*) mnuFilterByExt (Filter displayed files using *.<filter value>)


Image Lists

Image lists are collections of bitmaps. They logically group related bitmaps, and make accessing them easier. The first three image lists enumerated here actually work as a group. The imgSmallFolders and imgLargeFolders lists are both used by the list views, depending on the view mode. Each list item added to a list view must specify an image list index for its bitmap. The list view will determine which image list to use (one for Small, List, Detail, and Filtered view modes, and the other for Large view mode). Similarly, the scope pane will use both imgSmallFolders and imgSmallOpenFolders, depending on whether the scope item is selected. For this reason, the bitmaps in all three image lists must be coordinated. (For example, the LocalDrive image is at index 4 in all three image lists.)

FileExplorer defines the following image lists:

Name | imgSmallFolders
Description | Provides the bitmaps for use in the scope pane nodes and in the list views (in the Small, List, and Detail view modes). All the bitmaps in this image list are 16x16 pixels, and are saved in 24-bit color.
Images | Desktop MyComputer FloppyDrive LocalDrive CDRom RemoteDrive RemoteOfflineDrive Folder File Application AppExtension Unknown

Name | imgSmallOpenFolders
Description | Provides the bitmaps for use in the scope pane nodes, when a node is selected. All the bitmaps in this image list are 16x16 pixels, and are saved in 24-bit color.
Images | Desktop MyComputer FloppyDrive LocalDrive CDRom RemoteDrive RemoteOfflineDrive Folder File Application AppExtension Unknown

Name | imgLargeFolders
Description | Provides the bitmaps for use in the toolbar. All the bitmaps in this image list are 32x32 pixels, and are saved in 24-bit color.
Images | Desktop MyComputer FloppyDrive LocalDrive CDRom RemoteDrive RemoteOfflineDrive Folder File Application AppExtension Unknown

Name | imgButtons
Description | Provides the bitmaps for use in the toolbar. All the bitmaps in this image list are 16x16 pixels, and are saved in 24-bit color.
Images | Add Find Properties Run RunAs


Property Pages

Property pages are used for displaying the properties of scope items and list items as well as for the configuration wizard. Property pages are not explicitly associated with a node or list view at design time. At run time, the snap-in is asked for its property pages and uses an MMCPropertySheet object to add its property pages to MMC's property sheet.

To ensure that property pages are properly registered they must be associated with SnapInControl, the user control that is part of every snap-in project.

FileExplorer defines the following property pages:

Name | ppgGeneral
Description | Displays properties for files and folders.

Name | ppgWelcome
Description | First page of the configuration wizard.

Name | ppgNetDrives
Description | Second page of the configuration wizard. Asks whether FileExplorer should display network drives.

Name | ppgFolderAccess
Description | Third page of the configuration wizard. Asks whether FileExplorer should allow renaming and deleting folders.

Name | ppgFileAccess
Description | Fourth page of the configuration wizard. Asks whether FileExplorer should allow renaming and deleting files.

Name | ppgFinish
Description | Final page of the configuration wizard.

Name | ppgBrowser
Description | Displayed for the Internet Explorer node. Allows the user to type a URL for display in the result pane.


User Controls

In addition to SnapInControl, an additional user control is used for the OCX view displayed in response to the "About" task in the static node taskpad.

FileExplorer defines the following user controls:

Name | SnapInControl
Description | This control is part of every snap-in project and is used to associate the snap-in's property pages.

Name | AboutCtl
Description | Used for the OCX view displayed for the About node. Displays some informational text and a button that displays the same configuration wizard used when FileExplorer is added to a console.


Forms

FileExplorer uses a form to display the Run As dialog box:

Name | frmRunAs
Description | Displays the dialog box for the Run As toolbar button and menu item.


Classes

FileExplorer uses a class to hold the configuration information collected by the configuration wizard.

Name | ConfigData
Description | Holds the configuration information collected by the configuration wizard. The properties of this class are serialized in the .msc file so that settings are preserved along with a saved console.


Resources

FileExplorer uses a resource to hold the HTML page that displays the user guide when the user clicks the "How to Use FileExplorer" task on the static node taskpad.

Custom Resources USERGUIDE (Contains the HTML page for the user guide)


FileExplorer -- Event Handling

Platform SDK: Management Console

FileExplorer — Event Handling

[This is preliminary documentation and subject to change.]

The following topics describe the events handled by FileExplorer with a brief explanation as to why each one is implemented. For more information on how a particular event is implemented refer to the sample code, which contains detailed documentation for each handler.


SnapIn

FileExplorer handles the following events on the SnapIn object:

Event | Description
Initialize | Tells MMC that all static extensions are required. A required extension is preloaded when the snap-in is loaded. The only static extension is FileViewer but it is used so often that performance will be improved by preloading it.
QueryConfigurationWizard | Tells the snap-in manager that FileExplorer has a configuration wizard.
CreateConfigurationWizard | Adds the configuration wizard property pages to the snap-in manager's wizard property sheet.
ConfigurationComplete | Refreshes the scope pane after the configuration wizard is run from the menu button or from the About control.
WriteProperties | Saves the ConfigData class properties in the .msc file.
ReadProperties | Loads the ConfigData class properties from the .msc file.


ExtensionSnapIn

FileExplorer handles the following events on the ExtensionSnapIn object:

Event | Description
Expand | Used when FileExplorer is loaded as a namespace extension of Computer Management\System Tools on Windows 2000. Adds the ExtensionRoot node as a child of the expanding SystemTools node.


ScopeItems

FileExplorer handles the following events on the ScopeItems object:

Event | Description
Expand | If MyComputer is expanding, adds predefined nodes for all of the drives on the machine. If a drive or a folder is expanding, adds predefined nodes for all of its contained folders. If ExtensionRoot is expanding, adds the Desktop node. Note that the Desktop node is an auto-create child of the static node and does not need to be added when FileExplorer is created stand-alone. When created as an extension, Desktop must be added manually because it is not an auto-create child of ExtensionRoot. The auto-create children of Desktop will be created automatically in both cases.
Initialize | Defines column headers and sets list subitems for when the scope item is displayed in the result pane in detail mode. Column headers could be defined in the UI but it is done here as an example of adding them programmatically.
Rename | Renames the folder in the file system. Changes the ScopeItem object's display name and its column 1 text used for Detail mode.
Help | Displays this topic in this Help file. This Help file is merged with MMC's Help file because it is set as the value of the snap-in's HelpFile property at design time in the property browser.
PropertyChanged | Called when the property page for the Internet Explorer node (ppgBrowser) calls ScopeItem.PropertyChanged to inform the snap-in that the user has selected a new URL to display in the result pane. Reselects the Internet Explorer node and displays the specified URL.


Views

FileExplorer handles the following events on the Views object:

Event | Description
SetControlbar | Attaches the FileExplorer's toolbar and menu button to the console's control bar.
UpdateControlbar | Enables/disables toolbar buttons and menu buttons based on the current selection.
Select | Determines which console verbs to enable/disable based on the current selection. Updates the status bar with the number of selected objects and free disk space.
AddNewMenuItems | Adds FileExplorer's menu (mnuNew) that contains the items to appear on the New submenu of MMC's context menu. FileExplorer adds a Folder item to the New submenu when the selection is a drive or a folder.
AddTopMenuItems | Adds FileExplorer's menu (mnuContext) that contains the items to appear on the top of MMC's context menu. For single and multiple list items FileExplorer adds Run and Run As items.
QueryPaste | Tells MMC whether FileExplorer can accept a paste operation on the specified target ScopeItem object.
Paste | Copies or moves the specified folders and/or files to the folder represented by the target ScopeItem object.
Cut | Removes the moved ScopeItem objects. If there are moved list items and they are currently displayed in the result pane then removes them as well.
Delete | Deletes the folders and/or files from the file system and removes the corresponding ScopeItem objects and list items.
Refresh Removes all the child ScopeItem objects (representing subfolders) of the target ScopeItem and then re-enumerates them in the file system and adds them back. This allows picking up any file system changes that might have occurred outside of FileExplorer (for example in Windows Explorer) because FileExplorer does not automatically detect external changes.

If the target ScopeItem is also currently selected in the scope pane, refreshes the contents of the result pane.
Print Calls the system command processor using
Shell Environ("ComSpec") & " /c PRINT "

for every file in the selection.
QueryPagesFor | If the selection contains folders and/or list items then returns True. If the selection is the static node then returns True because the user is running the configuration wizard from the Explorer menu button or from the button on the About control.
CreatePropertyPages | If the selection contains folders and/or list items then adds the property pages and uses the InitData parameter of MMCPropertySheet.AddPage to pass the index into SelectedControls of the object that the page should display properties for. If the selection is the static node then calls SnapIn_CreateConfigurationWizard because that event handler needs to do the same thing (call MMCPropertySheet.AddWizardPage for each of the configuration wizard pages).
GetMultiSelectData | Fired when the user selects multiple items in a list view. Allows the snap-in to export data for the multiple selection. Adds data formats for all the file names, file paths, and folder paths.


ScopePaneItems

FileExplorer handles the following events on the ScopePaneItems object:

Event | Description
GetResultViewInfo | Used when the user selects the Internet Explorer node. Sets ViewType to URL and uses "about:blank" for the URL.


ResultViews

FileExplorer handles the following events on the ResultViews object:

Event | Description
Initialize | Populates the list view with list items.
InitializeControl | Sets the following properties on AboutCtl so it can run the configuration wizard: text to display, CurrentView.PropertySheetProvider, and static node scope item.
Activate | Displays the count of objects in the description bar.
CompareItems | Called during a sort when the user clicks a column header. Does comparisons for size and date. For other columns does not return a result to indicate to the runtime that it should do a default string comparison (for example, for the Name column).
ListItemDblClick | For a file's list view calls the Win32 API ShellExecute for the file.
ItemRename | Does the rename operation in the file system and updates the file's display in the list view. Calls MMCListItem.UpdateAllViews to tell any other existing views that might be displaying the file to update their display too.
ItemViewChange | Fired in each view in response to the MMCListItem.UpdateAllViews in ItemRename event. Updates the list item's display.
TaskClick | Start FileExplorer (Change result pane for static node to lvExplorerTop) MMC Home Page (Select Internet Explorer node with URL view displaying MMC home page on microsoft.com) About (Select About node)
TaskNotify | Called from the user guide HTML page using MMCCtrl.TaskNotify. Changes result pane for static node to StaticNodeTaskpad.
Print | Invokes the system command processor's print command to print the selected files.
Help | Displays this topic in this Help file. This Help file is merged with MMC's Help file because it is set as the value of the snap-in's HelpFile property at design time in the property browser.
FilterButtonClick | Displays a pop-up menu to allow the user to choose between filtering by name or by extension. (MMC 1.2 only.)
FilterChange | Refreshes the contents of the result pane. (MMC 1.2 only.)


Menus

FileExplorer handles the following menu events:

Event | Description
mnuNewFolder_Click | Creates a new folder under the selected drive or scope item.
mnuRun_Click | Calls the Win32 API ShellExecute for the file(s).
mnuRunAs_Click | Displays frmRunAs to prompt the user for a command line to run for the selected file(s).
mnuURL_Click | Displays the property sheet for the Internet Explorer node.


Toolbars

FileExplorer handles the following toolbar events:

Event | Description
tbrFileMgr_ButtonClick | Process new folder, run, and run as buttons as for context menu items.
tbrMenuButton_ButtonDropDown | Enables/disables menu items based on current selection.
tbrMenuButton_ButtonMenuClick | Process new folder, run, run as, and configuration items as for context menu items.


FileExplorer -- Data Sources

Platform SDK: Management Console

FileExplorer — Data Sources

[This is preliminary documentation and subject to change.]

In the FileExplorer sample, the source of the data being displayed is the FileSystemObject object from the Microsoft Scripting Runtime (Scrrun.dll). This is a separate COM object referenced by the snap-in. The direct user interface of the snap-in is coded in Visual Basic, but the data source does not have to be. In fact, every snap-in will acquire its data from a different source that is appropriate to that snap-in. These sources can be anything with which Visual Basic can communicate — Windows Management Instrumentation (WMI), ActiveX Data Objects (ADO) database connections, third-party COM objects, custom-built COM objects, legacy DLLs, host applications, socket connections, and so on.


FileExplorer -- Component Files

Platform SDK: Management Console

FileExplorer — Component Files

[This is preliminary documentation and subject to change.]

The FileExplorer sample consists of the following files.

File name | Description
AboutCtl.ctl | Source for user control used in OCX view displayed for About node
AboutCtl.ctx | Serialized binary objects associated with AboutCtl (icons, bitmaps, and so on)
ConfigData.cls | ConfigData class source
FileExplorer.dca | Binary serialization of snap-in designer
FileExplorer.dll | The built FileExplorer snap-in DLL
FileExplorer.dsr | The snap-in designer source
FileExplorer.dsx | Serialized binary objects associated with the designer (icons, bitmaps, and so on)
FileExplorer.exp | Exported functions file created by linker during build process
FileExplorer.lib | Exported functions library created by linker during build process
FileExplorer.pdb | Symbolic debug information created by linker during build process
FileExplorerSample.res | Resource file containing taskpad bitmaps and user guide HTML page
FileExplorerSample.vbp | Visual Basic project file — contains project properties
FileExplorerSample.vbw | Visual Basic workspace file — contains workspace settings
frmRunAs.frm | Run As prompt form source
ppgBrowser | Source for Internet Explorer node property page
ppgFileAccess.pag | Source for file access property page used in configuration wizard
ppgFinish.pag | Source for final property page used in configuration wizard
ppgFolderAccess.pag | Source for folder access property page used in configuration wizard
ppgGeneral.pag | Source for property page used for folders and files
ppgNetDrives.pag | Source for network drives property page used in configuration wizard
ppgWelcome.pag | Source for first property page used in configuration wizard
SnapInControl.ctl | User control used to associate property pages so that they are correctly registered
SnapInControl.ctx | Serialized binary objects associated with SnapInControl (icons, bitmaps, and so on)
StartExplorer.bmp | Bitmap used for "Start File Explorer" task in StaticNodeTaskpad
VBSnapInsSamples.chm | This Help file
WizardSymbol.bmp | Bitmap used for configuration button on AboutCtl


FileViewerExtension -- Design-Time Objects

Platform SDK: Management Console

FileViewerExtension — Design-Time Objects

[This is preliminary documentation and subject to change.]

This section provides descriptions of the objects defined by FileViewerExtension in the snap-in designer.


Extensions

The Extensions node defines the node types that the snap-in extends and the type of extensions implemented for each node type. The designer uses this information to register the extensions under the extended snap-in's keys in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MMC\NodeTypes.

Name | Directory
Description | FileExplorer's directory and drive ScopeItem objects
Extensions | Property pages

Name | FileExplorer
Description | FileExplorer's static node
Extensions | Taskpad

Name | lvExplorerFiles
Description | FileExplorer's files list view
Extensions | Task menu, property pages, toolbar


Toolbars and MenuButtons

Platform SDK: Management Console

Toolbars and Menu Buttons

[This is preliminary documentation and subject to change.]

Name | tbrViewer
Description | Defines FileViewerExtension's only toolbar
ImageList | imgButtons
Buttons | View File (Displays the file contents)

Name | tbrMenuButton
Description | Defines FileViewerExtension's only menu button
Buttons | FileViewer (ButtonMenus: View File)


Menus

Name | ViewerMenu
Description | Added to the All Tasks submenu of the console's context menu for single file selections
Items | ViewFile (Displays the contents of the selected file)


ImageLists

Name | imgToolbar
Description | Provides the bitmap used in the toolbar
Images | View File


Property Pages

Name | ppgViewFile
Description | Displays the contents of the file on a property page

Name | ppgDirStats
Description | Displays statistics about the selected folder


User Controls

Name | SnapInControl
Description | This control is part of every snap-in project and is used to associate the snap-in's property pages.

Name | ctlFileViewer
Description | Displays the contents of a file in a multiline edit control. Used by both ppgViewFile and frmFileViewer.


Forms

Name | frmFileViewer
Description | Displays the contents of a file


Resources

Bitmaps VIEWER: used for task added to FileExplorer's StaticNodeTaskpad


FileViewerExtension -- Event Handling

Platform SDK: Management Console

FileViewerExtension — Event Handling

[This is preliminary documentation and subject to change.]

The following topics describe the events handled by FileViewerExtension with a brief explanation as to why each one is implemented. For more information on how a particular event is implemented refer to the sample code, which contains detailed documentation for each handler.


ExtensionSnapIn

FileViewerExtension handles the following events on the ExtensionSnapIn object:

Event | Description
AddTaskMenuItems | Adds the View File item to the All Tasks submenu of MMC's context menu
CreatePropertyPages | Adds ppgViewFile or ppgDirStats to MMC property sheet depending on selected item
SetControlbar | Adds tbrViewer and tbrMenuButton to the control bar
UpdateControlbar | Enables/disables toolbar button and menu button based on selection
AddTasks | Adds "About FileViewer" task to FileExplorer's StaticNodeTaskpad
TaskClick | Displays a message box with about information


Menus

FileViewerExtension handles the following menu event:

Event | Description
ViewFile_Click | Creates frmFileViewer to display file contents


Toolbars

FileViewerExtension handles the following toolbar events:

Event | Description
tbrViewer_ButtonClick | Processes View File button as for context menu
tbrMenuButton_ButtonDropDown | Enables/disables View File item based on current selection.
tbrMenuButton_ButtonMenuClick | Processes View File item as for context menu


FileViewerExtension -- Data Sources

Platform SDK: Management Console

FileViewerExtension — Data Sources

[This is preliminary documentation and subject to change.]

FileViewerExtension receives all of its information (file paths, folder paths, and so on) from data exported by FileExplorer.


FileViewerExtension -- Component Files

Platform SDK: Management Console

FileViewerExtension — Component Files

[This is preliminary documentation and subject to change.]

The FileViewerExtension sample consists of the following files:

File name | Description
FileViewer.ctl | Source for user control used to display contents of files
FileViewer.ctx | Serialized binary objects associated with FileViewerCtl (icons, bitmaps, and so on)
FileViewerExtension.dca | Binary serialization of snap-in designer
FileViewerExtension.dsr | The snap-in designer source
FileViewerExtension.dsx | Serialized binary objects associated with the designer (icons, bitmaps, and so on)
FileViewerExtension.res | Resource file containing taskpad bitmap
FileViewerExtensionProj.dll | The built FileViewerExtension snap-in DLL
FileViewerExtensionProj.exp | Exported functions file created by linker during build process
FileViewerExtensionProj.lib | Exported functions library created by linker during build process
FileViewerExtensionProj.pdb | Symbolic debug information created by linker during build process
FileViewerExtensionProj.vbp | Visual Basic project file — contains project properties
FileViewerExtensionProj.vbw | Visual Basic workspace file — contains workspace settings
frmFileViewer.frm | Source for form that displays file contents
ppgDirStats.pag | Source for directory statistics property page
SnapInControl.ctl | User control used to associate property pages so that they are correctly registered
SnapInControl.ctx | Serialized binary objects associated with SnapInControl (icons, bitmaps, and so on)
Viewer.bmp | Bitmap used for toolbar button.


DriveStats -- Design-Time Objects

Platform SDK: Management Console

DriveStats — Design-Time Objects

[This is preliminary documentation and subject to change.]

This section provides descriptions of the objects defined by DriveStats in the snap-in designer.


Other Nodes

Name | DriveStats
Description | Added as a child of every drive node in FileExplorer
Result Views | lvDriveStats
ImageLists | None. Uses default images supplied by MMC.

Name | MyComputerStats
Description | Added as a child of the My Computer node in FileExplorer
Result Views | StatsListpad (uses lvDriveStats)
ImageLists | None. Uses default images supplied by MMC.


Extensions

The Extensions node defines the node types that the snap-in extends and the type of extensions implemented for each node type. The designer uses this information to register the extensions under the extended snap-in's keys in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MMC\NodeTypes.

Name | Directory
Description | FileExplorer's directory and drive ScopeItems
Extensions | Namespace

Name | MyComputer
Description | FileExplorer's My Computer node
Extensions | Namespace


Listviews

Platform SDK: Management Console

List Views

[This is preliminary documentation and subject to change.]

DriveStats defines the following list view:

Name | LvDriveStats
Description | This list view is associated with the DriveStats node. It displays various drive statistics. It is also associates with the StatsListpad result view used by the MyComputerStats node.
Default View Mode | Report
ImageLists | None. Uses default images supplied by MMC.
Column Headers | Stat, Value


Forms

DriveStats defines the following form:

Name | frmChooseDrive
Description | Displayed in response to the listpad button click. Allows the user to choose a different drive to display in StatsListpad.


DriveStats -- Event Handling

Platform SDK: Management Console

DriveStats — Event Handling

[This is preliminary documentation and subject to change.]

The following topics describe the events handled by DriveStats with a brief explanation as to why each one is implemented. For more information on how a particular event is implemented refer to the sample code, which contains detailed documentation for each handler.


ExtensionSnapIn

DriveStats handles the following event on the ExtensionSnapIn object:

Event | Description
Expand | If the expanding node is a FileExplorer drive, adds the DriveStats node underneath it. If the expanding node is FileExplorer's My Computer node then adds the MyComputerStats node underneath it.


ScopePaneItems

DriveStats handles the following event on the ScopePaneItems object:

Event | Description
GetResultView | If the lvDriveStats result view has been created once, then the DriveStats snap-in has requested to cache it in ResultViews_Deactivate and reuses it.


ResultViews

DriveStats handles the following events on the ResultViews object:

Event | Description
Initialize | Populates the list view with drive statistics
Deactivate | Tells the designer runtime that the result view should be cached
ResultViews_ListpadButtonClick | Displays frmChooseDrive to allow the user to choose a different drive to display in StatsListpad.


DriveStats -- Data Sources

Platform SDK: Management Console

DriveStats — Data Sources

[This is preliminary documentation and subject to change.]

DriveStats receives all of its information (file paths, folder paths, and so on) from data exported by FileExplorer.


DriveStats -- Component Files

Platform SDK: Management Console

DriveStats — Component Files

[This is preliminary documentation and subject to change.]

The DriveStats sample consists of the following files:

File name | Description
DriveStats.dca | Binary serialization of snap-in designer
DriveStats.dsr | The snap-in designer source
DriveStats.dsx | Serialized binary objects associated with the designer (icons, bitmaps, and so on)
DriveStatsProj.dll | The built DriveStats snap-in DLL
DriveStatsProj.exp | Exported functions file created by linker during build process
DriveStatsProj.lib | Exported functions library created by linker during build process
DriveStatsProj.pdb | Symbolic debug information created by linker during build process
DriveStatsProj.vbp | Visual Basic project file — contains project properties
DriveStatsProj.vbw | Visual Basic workspace file — contains workspace settings
frmchoosedrive.frm | Form that allows user to choose drive in StatsListpad.
SnapInControl.ctl | User control used to associate property pages so that they are correctly registered


ComDetect -- Design-Time Objects

Platform SDK: Management Console

ComDetect — Design-Time Objects

[This is preliminary documentation and subject to change.]

The following section describes the design-time objects defined by ComDetect.


Extensions

ComDetect extends the following node:

Name | lvExplorerFiles
Description | FileExplorer's files list view
Extensions | Task context menu


Menus

ComDetect defines the following menu:

Name | mnuDetect
Description | Added to the All Tasks menu for all files with the extension .dll
Items | IsComServer (Displays message box indicating whether the selected file is also an in-process COM server)


ComDetect -- Event Handling

Platform SDK: Management Console

ComDetect — Event Handling

[This is preliminary documentation and subject to change.]

The following section defines the events handled by ComDetect at run time.


ExtensionSnapIn

ComDetect handles the following event on the ExtensionSnapIn object:

Event | Description
AddTaskMenuItems | Adds the Is this file a COM server? item to the All Tasks submenu of MMC's context menu


Menus

ComDetect handles the following menu event:

Event | Description
IsCOMServer_Click | Uses Win32 API to check whether DLL exports the function DllRegisterServer and displays message box indicating whether the selected file is also an in-process COM server


ComDetect -- Data Sources

Platform SDK: Management Console

ComDetect — Data Sources

[This is preliminary documentation and subject to change.]

ComDetect receives all of its information (file paths, folder paths, and so on) from data exported by FileExplorer.


ComDetect -- Component Files

Platform SDK: Management Console

ComDetect — Component Files

[This is preliminary documentation and subject to change.]

The ComDetect sample consists of the following files:

File name | Description
ComDetect.dca | Binary serialization of snap-in designer
ComDetect.dsr | The snap-in designer source
ComDetect.dsx | Serialized binary objects associated with the designer (icons, bitmaps, and so on)
ComDetectProj.dll | The built ComDetect snap-in DLL
ComDetectProj.exp | Exported functions file created by linker during build process
ComDetectProj.lib | Exported functions library created by linker during build process
ComDetectProj.pdb | Symbolic debug information created by linker during build process
ComDetectProj.vbp | Visual Basic project file — contains project properties
ComDetectProj.vbw | Visual Basic workspace file — contains workspace settings
SnapInControl.ctl | User control used to associate property pages so that they are correctly registered


Error Handling

Run-time errors in Visual Basic can come from many sources, and can potentially result from any statement or object access. For the purpose of these sample snap-ins, the error-handling mechanism is rather rudimentary. There is a small error handler set up for each method and event that will simply report the error that occurred and allow processing to continue. Obviously, in a real-life application error handling would need to be much more robust and fine-tuned. Not all errors are fatal. Some errors could trigger compensating logic that would allow the operation to be re-executed successfully. Some errors should merely be reported to the user. Some errors are catastrophic and will prevent the snap-in from continuing. The manner in which any snap-in handles errors should be carefully analyzed and designed into the snap-in.