0

Looking into how to provide the icon for my custom mmc snap-ins.

Language = c#

pdiddy
  • 6,217
  • 10
  • 50
  • 111

3 Answers3

3

If what you want is to provide the bitmaps for your DLL in the Add/Remove dialog in MMC, You need to specify the SnapInAbout attribute, and provide a Resource DLL, and an id for the bitmap.

Huh?

More complete answer here.

And also in the MMC SDK sample, there's working code.

Cheeso
  • 189,189
  • 101
  • 473
  • 713
  • thanks! Cuz when I add my custom snap in, the default icon is a folder. I want it to be one of my icon – pdiddy Dec 19 '09 at 15:48
  • This article explains everything with more details [Adding SnapInAbout](http://binarychef.com/community/Blog/TabId/95/PostId/79/adding-about-information-for-your-net-mmc-snap-in-icons-in-the-add-or-remove-snap-ins-dialog.aspx). – Pallab Pain Jun 30 '16 at 10:46
3

You cannot do this in C#. You have to create a native Win32 dll. In other words: create a C++ project. This is not that scary.

Once you add a Win32 Project Visual C++, you can use the wizard to add a resource file. From there you can use the tools to add an icon, and the text descriptions.

If everything goes correct you will have a resource.h file generated in the folder "Header Files". Open that file, and you will see something like

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by ConsoleResources.rc
//
#define IDB_BITMAP4                     101
#define IDB_BITMAP5                     102
#define IDI_ICON2                       103
#define IDS_COMPANY                     104
#define IDS_PRODUCT_NAME                105
#define IDS_DESCRIPTION                 106

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        107
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1001
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

These numbers 101,... are the numbers that have to correspond with the SnapInAbout attribute that you put in your C# file.

[SnapInAbout("Your.Unmanaged.dll", ApplicationBaseRelative = true, 
 VendorId = 104, DisplayNameId = 105, DescriptionId = 106, IconId = 103,
 SmallFolderBitmapId = 110, LargeFolderBitmapId = 102, 
 SmallFolderSelectedBitmapId = 101)]    
Sentient
  • 2,185
  • 2
  • 19
  • 20
  • Even less scary is to get the sysmgmt samples from the Windows SDK and look at the \mmc3.0\LocalizedRegistrationSample which has everything set up ready for you to add to your own snapin. – gbjbaanb Oct 09 '13 at 15:15
2

I found a way. I had to add the images to the SmallImages collection of the SnapIn.

And then each scopenode has a ImageIndex and SelectedImageIndex. All you have is to set those property to the correct index of the SmallImages Collection.

pdiddy
  • 6,217
  • 10
  • 50
  • 111
  • Would I be correct to assume that this only allows you to change the icon after the snap-in is loaded, but does not affect the snap-in icon when browsing which snap-ins to add to the console? – BlueMonkMN Oct 01 '15 at 18:55