绪论The article/code snippet helps in creation of MMC Snapin using C#. 背景The framework for building management consoles for Windows NT/2000 is developed by Jim. Jim is the author for ironringsoftware.com. In our article we will be using this framework to derive the UI for the management console. Detailed step for generating the snapin console is explained below. 代码使用步骤Here are the steps to use the MMC library created by the author at ironringsoftware.com to create management consoles for Windows NT/2000 Step 1: 下载框架You need to download the latest source of MMC Snapin Framework from ironringsoftware.com . The zip file downloaded contains three projects.
Step 2: 查看示例
Step 3: 初始化
Step 4:如何创建新接点例1:Let us take an example of creating a node which contains all the directory information on the left pane and the file information in the result pane.
//This is the variable which holds the data passed from the framework.
protected Hashtable m_Properties;
m_Properties = new Hashtable();
public Hashtable Properties {
get { return m_Properties; }
set { m_Properties = value; }
}
//
//Code block for DirectoryNode.cs
//
using System;
using System.IO;
using System.Data;
using System.Runtime.InteropServices;
namespace Ironring.Management.MMC {
/// <summary>
/// Any node which we create should be derived from the BaseNode.
/// This node will get displayed in the left pane of the MMC.
///
/// </summary>
public class DirectoryNode : BaseNode {
protected DataTable m_table = null;
public DirectoryNode(SnapinBase snapin) : base(snapin) {
}
/// <summary>
/// This is the public property to get/set the datatable value.
/// This datatable values are the ones which gets displayed in the right pane
/// of the MMC for the respective node item selected in the left pane.
/// </summary>
public DataTable Table {
get { return m_table; }
set { m_table = value; }
}
/// <summary>
/// This method is called by the MMC snap to populate the data for listview
/// in the right pane, for the respective node item selected in the left pane.
/// </summary>
public override void OnShow() {
IConsole2 console = Snapin.ResultViewConsole;
IHeaderCtrl2 header = console as IHeaderCtrl2;
OnShowHeader(header);
IResultData rdata = console as IResultData;
OnShowData(rdata);
rdata.SetViewMode((int)ViewMode.Report);
}
/// <summary>
/// This method is called by the OnShow() method to
/// display header for the listview
/// in the right pane, for the respective node item selected in the left pane.
/// </summary>
public virtual void OnShowHeader(IHeaderCtrl2 header) {
try {
if (Table != null) {
foreach (DataColumn col in Table.
|
用C# 创建 MMC Snapin
最新推荐文章于 2021-06-22 17:09:39 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)