ShellOverlays Class

Properties   Methods   Events   Config Settings   Errors  

The ShellOverlays class enables adding overlay icons over any files and folders displayed by the Windows Shell.

Syntax

ShellOverlays

Remarks

The ShellOverlays class provides a simple way to add overlay icons over file and folder icons in File Explorer.

The system image list for overlay icons is limited to 16 icons, of which four (4) are used by the Windows Shell, leaving just 12 icons for applications. Cloud synchronization applications, version control system clients (SmartSVN, SmartGit, Tortoise SVN and Tortoise Git, etc.) and other software products each register multiple overlay icons. So, it is not guaranteed that an overlay icon set in the class will be the one to display over the particular shell item.

The class pre-registers ten (10) overlay icons for one license and lets the application use any number of them, disabling the unused icons so that they do not get in the way of other applications.

Configuring Overlay Icons

The first step in using the class is to configure the icons that File Explorer should display. The OverlayIcons collection is automatically prepopulated with ten icon slots your application can use to define overlay icons. Each slot represents an icon that can be registered with the system. To configure an icon in a slot, set the IconPath property to specify the file that contains the icon, set the IconIndex property to indicate its index within that file, and enable it by setting Enabled to true. import callback.CBFSShell; ShellOverlays m_Overlays = new ShellOverlays(); // Only configure the first icon in the 'OverlayIcons' collection OverlayIcon icon = m_Overlays.OverlayIcons[0]; // The path to a file that contains your icons. This can point to an .exe, .dll, or .ico file. icon.IconPath = "C:\\PATH\\TO\\ICON\\FILE.ico"; // The index of the icon in that .dll file icon.IconIndex = 1; // This must be set to true for the icon to be visible in File Explorer icon.Enabled = true;

Installation

Next, call the Install method. This will load a proxy dynamic link library (DLL) into File Explorer to facilitate communication with the Windows Shell. In addition, this will prompt the class to register the configured overlay icons to the Windows Registry. Installation should be done at least once before using the library on a new system, but it may be done several times to update the desired icon configurations. m_Overlays.Install();

Defining File Masks

After installation, specify which files and folders are candidates for receiving overlay icons by using the IncludeMasks and ExcludeMasks properties. The IncludeMasks property specifies which files and folders are eligible for overlays. ExcludeMasks can override these selections. // Only consider overlays for .txt files in the "Documents" folder m_Overlays.IncludeMasks = "C:\\Users\\User\\Documents\\*.txt"; // Exclude any files named "test.txt" from receiving an overlay icon m_Overlays.ExcludeMasks = "C:\\Users\\User\\Documents\\test.txt";

Initialization and Activation

Once the overlay icons and file masks are configured, call the Initialize method to perform necessary setup tasks. Then, call the Activate method to start processing Windows Shell requests and display the overlay icons. m_Overlays.Initialize(); m_Overlays.Activate();

Displaying Overlay Icons

While the class is active, the UseIcon event will fire for each file and folder that matches the previously defined file masks. This event is fired just before an item is displayed in File Explorer, providing your application with an opportunity to decide whether a candidate overlay icon should be applied.

When the event is fired, the FilePath parameter contains the full path of the file or folder being evaluated, and the Attributes parameter provides its file system attributes. In addition, the IconNumber parameter identifies which candidate overlay icon from the prepopulated OverlayIcons collection is being considered. Initially, the Use parameter is set to false. If your application determines that the overlay icon should be applied to the item, simply enable the icon by setting Use to true. m_Overlays.OnUseIcon += (sender, e) => { // Identifies the candidate overlay icon from the OverlayIcons collection. var iconNumber = e.IconNumber; // The full path of the file or folder being evaluated. var filePath = e.FilePath; // File system attributes of the file or folder. var attributes = e.Attributes; // Display overlay icon 0 for the current file or folder if (e.IconNumber == 0) { e.Use = true; } }; Once the Use parameter is set to true, the overlay icons should be visible in File Explorer on top of any files or folders the event was fired for.

Deactivation and Uninstall

To stop serving overlay icons while still keeping your configuration intact, call the Deactivate method. m_Overlays.Deactivate(); To unregister the overlay icons from the Windows Registry, call the Uninstall method. This action will also unregister the proxy DLL from File Explorer, which typically is performed when the application should be removed from the system. m_Overlays.Uninstall();

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

ExcludeMasksSpecifies one or more path masks used to exclude files and folders from receiving overlay icons.
IncludeMasksSpecifies one or more path masks that define which files and folders are eligible for overlay icons.
OverlayIconsContains a collection of overlay icon information.
ProxyPathSpecifies the path to the native proxy DLL.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

ActivateThis method makes overlay icons available to the system.
ConfigSets or retrieves a configuration setting.
DeactivateStops monitoring changes.
InitializeInitializes the core library.
InstallRegisters icon overlay information in the system.
UninstallUnregisters icon overlays from the system.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

ErrorFires when an unhandled error occurs during an event.
UseIconFires when the Windows Shell queries for overlay icons.

Config Settings


The following is a list of config settings for the class with short descriptions. Click on the links for further details.

IconSetNameA human-readable name of the overlay icon set.
IPCFormatThe fixed name of the RPC endpoint.
IsInstalledSpecifies whether the installation was performed.
ProductGUIDID of the proxy DLL.
ServerStartArgumentsThe arguments to pass with the command.
ServerStartCommandLineThe command line to run when the server is not available.
ServerStartOperationThe operation verb.
ServerStartShowOptionDefines how the application windows should be shown.
ServerStartTimeToWaitOptional time to wait before retrying RPC connection.
ServerStartWorkingDirectoryThe working directory.
BuildInfoInformation about the product's build.
LicenseInfoInformation about the current license.

ExcludeMasks Property (ShellOverlays Class)

Specifies one or more path masks used to exclude files and folders from receiving overlay icons.

Syntax

ANSI (Cross Platform)
char* GetExcludeMasks();
int SetExcludeMasks(const char* lpszExcludeMasks); Unicode (Windows) LPWSTR GetExcludeMasks();
INT SetExcludeMasks(LPCWSTR lpszExcludeMasks);
char* cbfsshell_shelloverlays_getexcludemasks(void* lpObj);
int cbfsshell_shelloverlays_setexcludemasks(void* lpObj, const char* lpszExcludeMasks);
QString GetExcludeMasks();
int SetExcludeMasks(QString qsExcludeMasks);

Default Value

""

Remarks

This property is used to prevent overlay icons from appearing over specific files and folders. If a file or folder matches any of the specified masks, the UseIcon event will not fire for it, and the class will inform the Windows Shell that its overlay icons should not be applied.

A mask may contain any combination of valid file name characters and wildcards (the * and ? characters). Multiple mask values should be separated with the LF character (numeric code 10).

Example (Single mask): // Exclude any .txt files from receiving an overlay icon m_Overlays.ExcludeMasks = "C:\\Users\\User\\Documents\\*.txt";

Example (Multiple masks): // Exclude the following files from receiving overlay icons: // 1) Files named "test.txt" that are located in the 'C:\Users\User\Documents\ directory // 2) Files named "test2.txt" that are located in the 'C:\Content\' directory m_Overlays.ExcludeMasks = "C:\\Users\\User\\Documents\\test.txt" + "\x0a" + // LF character marks the start of a new mask "C:\\Content\\test2.txt";

Combining Inclusion and Exclusion Masks

The IncludeMasks and ExcludeMasks properties may be used together or separately. When both properties are set, the name of the file or directory being evaluated by the Windows Shell must first match IncludeMasks before it is checked against ExcludeMasks. The UseIcon event will only fire for the file or directory if it matches the inclusion masks in IncludeMasks and does not match the exclusion masks in ExcludeMasks. This way, exclusion masks override the result of inclusion masks.

Data Type

String

IncludeMasks Property (ShellOverlays Class)

Specifies one or more path masks that define which files and folders are eligible for overlay icons.

Syntax

ANSI (Cross Platform)
char* GetIncludeMasks();
int SetIncludeMasks(const char* lpszIncludeMasks); Unicode (Windows) LPWSTR GetIncludeMasks();
INT SetIncludeMasks(LPCWSTR lpszIncludeMasks);
char* cbfsshell_shelloverlays_getincludemasks(void* lpObj);
int cbfsshell_shelloverlays_setincludemasks(void* lpObj, const char* lpszIncludeMasks);
QString GetIncludeMasks();
int SetIncludeMasks(QString qsIncludeMasks);

Default Value

""

Remarks

This property is used to filter files and folders that should receive overlay icons. When set, the UseIcon event will only fire for files and folders that match the specified masks. If empty, the UseIcon will fire for all files and folders queried by the Windows Shell when they are about to be displayed in File Explorer.

Combining Inclusion and Exclusion Masks

The IncludeMasks and ExcludeMasks properties may be used together or separately. When both properties are set, the name of the file or directory being evaluated by the Windows Shell must first match IncludeMasks before it is checked against ExcludeMasks. The UseIcon event will only fire for the file or directory if it matches the inclusion masks in IncludeMasks and does not match the exclusion masks in ExcludeMasks. This way, exclusion masks override the result of inclusion masks.

A mask may contain any combination of valid file name characters and wildcards (the * and ? characters). Multiple mask values should be separated with the LF character (numeric code 10).

Example (Single mask): // Allow any .txt files to receive overlay icons m_Overlays.ExcludeMasks = "C:\\Users\\User\\Documents\\*.txt";

Example (Multiple masks): // Include the following files from receiving overlay icons: // 1) Files named "test.txt" that are located in the 'C:\Users\User\Documents\ directory // 2) Files named "test2.txt" that are located in the 'C:\Content\' directory m_Overlays.ExcludeMasks = "C:\\Users\\User\\Documents\\test.txt" + "\x0a" + // LF character marks the start of a new mask "C:\\Content\\test2.txt";

Combining Inclusion and Exclusion Masks

The IncludeMasks and ExcludeMasks properties may be used together or separately. When both properties are set, the name of the file or directory being evaluated by the Windows Shell must first match IncludeMasks before it is checked against ExcludeMasks. The UseIcon event will only fire for the file or directory if it matches the inclusion masks in IncludeMasks and does not match the exclusion masks in ExcludeMasks. This way, exclusion masks override the result of inclusion masks.

Data Type

String

OverlayIcons Property (ShellOverlays Class)

Contains a collection of overlay icon information.

Syntax

CBFSShellList<CBFSShellOverlayIcon>* GetOverlayIcons();

int cbfsshell_shelloverlays_getoverlayiconscount(void* lpObj);
int cbfsshell_shelloverlays_getoverlayiconenabled(void* lpObj, int overlayiconindex);
int cbfsshell_shelloverlays_setoverlayiconenabled(void* lpObj, int overlayiconindex, int bOverlayIconEnabled);
int cbfsshell_shelloverlays_getoverlayiconiconindex(void* lpObj, int overlayiconindex);
int cbfsshell_shelloverlays_setoverlayiconiconindex(void* lpObj, int overlayiconindex, int iOverlayIconIconIndex);
char* cbfsshell_shelloverlays_getoverlayiconiconpath(void* lpObj, int overlayiconindex);
int cbfsshell_shelloverlays_setoverlayiconiconpath(void* lpObj, int overlayiconindex, const char* lpszOverlayIconIconPath);
int cbfsshell_shelloverlays_getoverlayiconpriority(void* lpObj, int overlayiconindex);
int cbfsshell_shelloverlays_setoverlayiconpriority(void* lpObj, int overlayiconindex, int iOverlayIconPriority);
int GetOverlayIconsCount();

bool GetOverlayIconEnabled(int iOverlayIconIndex);
int SetOverlayIconEnabled(int iOverlayIconIndex, bool bOverlayIconEnabled); int GetOverlayIconIconIndex(int iOverlayIconIndex);
int SetOverlayIconIconIndex(int iOverlayIconIndex, int iOverlayIconIconIndex); QString GetOverlayIconIconPath(int iOverlayIconIndex);
int SetOverlayIconIconPath(int iOverlayIconIndex, QString qsOverlayIconIconPath); int GetOverlayIconPriority(int iOverlayIconIndex);
int SetOverlayIconPriority(int iOverlayIconIndex, int iOverlayIconPriority);

Remarks

This property holds a collection of OverlayIcon objects. Due to system constraints, this collection is pre-populated and limited to ten (10) items. which can be disabled or enabled by an application.

This property is read-only and not available at design time.

Data Type

CBFSShellOverlayIcon

ProxyPath Property (ShellOverlays Class)

Specifies the path to the native proxy DLL.

Syntax

ANSI (Cross Platform)
char* GetProxyPath();
int SetProxyPath(const char* lpszProxyPath); Unicode (Windows) LPWSTR GetProxyPath();
INT SetProxyPath(LPCWSTR lpszProxyPath);
char* cbfsshell_shelloverlays_getproxypath(void* lpObj);
int cbfsshell_shelloverlays_setproxypath(void* lpObj, const char* lpszProxyPath);
QString GetProxyPath();
int SetProxyPath(QString qsProxyPath);

Default Value

""

Remarks

This property may be used to specify the path to the native proxy DLL, which is loaded by the Windows Shell. The value may be in one of the following formats:

  1. A directory path containing proxy DLLs. For example: C:\Users\User\Documents\CBFS Shell 2024\proxy. In this case, the class will automatically choose the first DLL with the appropriate architecture.
  2. A full file path with wildcards in the filename. For example C:\Users\User\Documents\CBFS Shell 2024\proxy\CBFSShell.*.x64. In this case, the class will automatically choose the first DLL that matches the specified pattern.

If left empty, the class will automatically attempt to locate the appropriate DLL by searching the directory where the application's executable resides.

Data Type

String

Activate Method (ShellOverlays Class)

This method makes overlay icons available to the system.

Syntax

ANSI (Cross Platform)
int Activate();

Unicode (Windows)
INT Activate();
int cbfsshell_shelloverlays_activate(void* lpObj);
int Activate();

Remarks

Use this method to make the overlay icons available to the system.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Config Method (ShellOverlays Class)

Sets or retrieves a configuration setting.

Syntax

ANSI (Cross Platform)
char* Config(const char* lpszConfigurationString);

Unicode (Windows)
LPWSTR Config(LPCWSTR lpszConfigurationString);
char* cbfsshell_shelloverlays_config(void* lpObj, const char* lpszConfigurationString);
QString Config(const QString& qsConfigurationString);

Remarks

Config is a generic method available in every class. It is used to set and retrieve configuration settings for the class.

These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.

To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).

To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.

Error Handling (C++)

This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.

Deactivate Method (ShellOverlays Class)

Stops monitoring changes.

Syntax

ANSI (Cross Platform)
int Deactivate();

Unicode (Windows)
INT Deactivate();
int cbfsshell_shelloverlays_deactivate(void* lpObj);
int Deactivate();

Remarks

Use this method to stop monitoring for changes and unregister as an observer of change notifications.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Initialize Method (ShellOverlays Class)

Initializes the core library.

Syntax

ANSI (Cross Platform)
int Initialize();

Unicode (Windows)
INT Initialize();
int cbfsshell_shelloverlays_initialize(void* lpObj);
int Initialize();

Remarks

This method initializes the core library and must be called each time the application starts before attempting to use other class's methods. The two exceptions are Install and Uninstall, which don't require advance initialization.

If the application explicitly specifies the path to the proxy DLL, it should do this through the ProxyPath property before calling this method.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Install Method (ShellOverlays Class)

Registers icon overlay information in the system.

Syntax

ANSI (Cross Platform)
int Install();

Unicode (Windows)
INT Install();
int cbfsshell_shelloverlays_install(void* lpObj);
int Install();

Remarks

This method is used to install the native proxy DLL that integrates with the Windows Shell and register the icon overlay information in the system.

Before calling this method, the application should set up the values of the items of the OverlayIcons collection. Each icon, if used, should have its fields defined. Also, you may change the default value of the ProxyPath property and the IconSetName configuration setting, which are used during installation.

The registration information for overlay icons is written to the registry for all users. Due to this, administrative rights are required to execute this method successfully. If the user account of the process that calls this method does not have such rights, the call will fail with an ERROR_PRIVILEGE_NOT_HELD (0x0522) error.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Uninstall Method (ShellOverlays Class)

Unregisters icon overlays from the system.

Syntax

ANSI (Cross Platform)
int Uninstall();

Unicode (Windows)
INT Uninstall();
int cbfsshell_shelloverlays_uninstall(void* lpObj);
int Uninstall();

Remarks

This method is used to uninstall the proxy DLL that integrates with the Windows Shell from the system.

Before calling this method, you may change the default value of the Scope property.

Registry Scope and User Permissions

The Scope property specifies whether the information is written to the registry for the current user or for all users.

In the latter case, administrative rights are required to execute this method successfully. If the user account of the process that calls this method does not have such rights, the call will fail with an ERROR_PRIVILEGE_NOT_HELD (0x0522) error.

Handling multiple classes

As ShellFolder and ShellMenu classes share a proxy DLL and a product GUID, they store some common information in a registry key. Calling the Uninstall method of one of the components will delete a shared registry key as well.

Each class should be uninstalled properly by calling the corresponding Uninstall method. At the same time, if an application needs to uninstall just one class and keep the other(s), it should call the Uninstall method of that class and then call the Install method of the other classes to restore the common information in the shared registry key.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Error Event (ShellOverlays Class)

Fires when an unhandled error occurs during an event.

Syntax

ANSI (Cross Platform)
virtual int FireError(ShellOverlaysErrorEventParams *e);
typedef struct {
int ErrorCode;
const char *Description; int reserved; } ShellOverlaysErrorEventParams;
Unicode (Windows) virtual INT FireError(ShellOverlaysErrorEventParams *e);
typedef struct {
INT ErrorCode;
LPCWSTR Description; INT reserved; } ShellOverlaysErrorEventParams;
#define EID_SHELLOVERLAYS_ERROR 1

virtual INT CBFSSHELL_CALL FireError(INT &iErrorCode, LPSTR &lpszDescription);
class ShellOverlaysErrorEventParams {
public:
  int ErrorCode();

  const QString &Description();

  int EventRetVal();
  void SetEventRetVal(int iRetVal);
};
// To handle, connect one or more slots to this signal. void Error(ShellOverlaysErrorEventParams *e);
// Or, subclass ShellOverlays and override this emitter function. virtual int FireError(ShellOverlaysErrorEventParams *e) {...}

Remarks

This event fires when an unhandled error occurs. Developers can use this information to track down unhandled errors that occur in the class.

ErrorCode contains an error code and Description contains a textual description of the error.

UseIcon Event (ShellOverlays Class)

Fires when the Windows Shell queries for overlay icons.

Syntax

ANSI (Cross Platform)
virtual int FireUseIcon(ShellOverlaysUseIconEventParams *e);
typedef struct {
int IconNumber;
const char *FilePath;
int Attributes;
int Apply; int reserved; } ShellOverlaysUseIconEventParams;
Unicode (Windows) virtual INT FireUseIcon(ShellOverlaysUseIconEventParams *e);
typedef struct {
INT IconNumber;
LPCWSTR FilePath;
INT Attributes;
BOOL Apply; INT reserved; } ShellOverlaysUseIconEventParams;
#define EID_SHELLOVERLAYS_USEICON 2

virtual INT CBFSSHELL_CALL FireUseIcon(INT &iIconNumber, LPWSTR &lpszFilePath, INT &iAttributes, BOOL &bApply);
class ShellOverlaysUseIconEventParams {
public:
  int IconNumber();

  const QString &FilePath();

  int Attributes();

  bool Apply();
  void SetApply(bool bApply);

  int EventRetVal();
  void SetEventRetVal(int iRetVal);
};
// To handle, connect one or more slots to this signal. void UseIcon(ShellOverlaysUseIconEventParams *e);
// Or, subclass ShellOverlays and override this emitter function. virtual int FireUseIcon(ShellOverlaysUseIconEventParams *e) {...}

Remarks

This event fires when the Windows Shell requests overlay icons for a file or folder about to be displayed in File Explorer. The event provides an opportunity to determine whether a candidate overlay icon should be a applied to the file or folder the event was fired for.

To handle the event properly, an application may first use the FilePath and Attributes parameters to identify the file or folder the event was fired for. Then, it can determine if the icon identified by IconNumber should be displayed over it. The application can then set Apply to true to display the icon, or to false to skip it.

IconNumber represents the index of the icon in the OverlayIcons collection. Its value may be used to determine whether this icon should be applied to the file or folder the event was fired for.

FilePath specifies the full path of the file or folder being evaluated. This value may be used alongside Attributes to determine if the specified file or folder should receive the overlay icon identified by IconNumber.

Attributes contains the file system attributes of the file or folder being evaluated. For the full list of attributes, please see Microsoft documentation. This value may be used alongside FilePath to determine if the specified file or folder should receive the overlay icon identified by IconNumber.

Apply indicates whether the overlay icon should be applied to the item. This value should be set to true to display the icon for the file or folder identified by FilePath and Attributes. By default, this value is set to false.

If multiple registered overlay icons are to be used, the Windows Shell has internal rules to decide which one will be applied, and the class has no control over this decision.

Example: m_Overlays.OnUseIcon += (sender, e) => { // Identifies the candidate overlay icon from the OverlayIcons collection. var iconNumber = e.IconNumber; // The full path of the file or folder being evaluated. var filePath = e.FilePath; // File system attributes of the file or folder. var attributes = e.Attributes; // Display overlay icon 0 for a specific file if (filePath.Equals("C:\\Users\\User\\Documents\\test.txt") && e.IconNumber == 0) { e.Use = true; } };

UI Considerations

Event handlers are called in the context of threads that run in the MTA (multithreaded apartment) state. This state is not suitable for showing UI elements. Thus, event handlers should create an STA thread and use it to display a needed window. For example:

var thread = new Thread(() => { ... } // "..." is the code that an event handler executes in a helper thread thread.SetApartmentState(ApartmentState.STA); thread.IsBackground = true; thread.Start(); thread.Join(); // optional, if your code should work synchronously

OverlayIcon Type

Represents an overlay icon.

Syntax

CBFSShellOverlayIcon (declared in cbfsshell.h)

Remarks

This type represents an overlay icon exposed to the Windows Shell by the class.

An icon is enabled when both the Enabled field is set to true and IconIndex and IconPath fields are set to appropriate values.

The following fields are available:

Fields

Enabled
int

Default Value: FALSE

Specifies that an overlay icon is enabled.

This field specifies whether the overlay icon is enabled and can be used.

IconIndex
int

Default Value: -1

The index of the icon within the file.

This field determines which icon is displayed for the item when the IconPath field contains a path to an EXE or DLL file. Its value should be the index of the specific icon within the resources of the DLL or EXE file in IconPath.

Set this field to -1 if the file referenced by the IconPath field specifies a file with just one icon.

IconPath
char*

Default Value: ""

An absolute name with path of a file with the icon.

This field should be set to the path of a file that contains an icon. Together with the IconIndex field, this value tells the Windows Shell which icon to display. If the file contains just one icon, set IconIndex to -1.

The Windows Shell supports loading of overlay icons from EXE, DLL, and ICO files.

Priority
int

Default Value: 0

The priority of the icon.

The priority is used by the Windows Shell to determine which of the icon to display when several overlay icons are available for an item.

Note: The Windows Shell has internal rules to determine overlay icon priority. The value of this field only acts as a hint for the cases when these rules do not apply.

The acceptable values are from 0 to 100, with 0 recommended for all cases.

CBFSShellList Type

Syntax

CBFSShellList<T> (declared in cbfsshell.h)

Remarks

CBFSShellList is a generic class that is used to hold a collection of objects of type T, where T is one of the custom types supported by the ShellOverlays class.

Methods

GetCount This method returns the current size of the collection.

int GetCount() {}

SetCount This method sets the size of the collection. This method returns 0 if setting the size was successful; or -1 if the collection is ReadOnly. When adding additional objects to a collection call this method to specify the new size. Increasing the size of the collection preserves existing objects in the collection.

int SetCount(int count) {}

Get This method gets the item at the specified position. The index parameter specifies the index of the item in the collection. This method returns NULL if an invalid index is specified.

T* Get(int index) {}

Set This method sets the item at the specified position. The index parameter specifies the index of the item in the collection that is being set. This method returns -1 if an invalid index is specified. Note: Objects created using the new operator must be freed using the delete operator; they will not be automatically freed by the class.

T* Set(int index, T* value) {}

Config Settings (ShellOverlays Class)

The class accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the Config method.

ShellOverlays Config Settings

IconSetName:   A human-readable name of the overlay icon set.

This configuration setting is used to specify a human-readable name of the set of icons when the icon-related records are written in the registry. The name acts as a prefix, to which the icon number is added. Adjust this setting before calling the Install method. If not set, a license-id-based value is constructed and used during the installation.

IPCFormat:   The fixed name of the RPC endpoint.

If the Windows Shell and the server operate in different desktop sessions, set this configuration before installing the native proxy DLL.

IsInstalled:   Specifies whether the installation was performed.

This configuration setting returns true if the class finds the required registry entries, put there by a previous call to the Install method; otherwise, false is returned. In the latter case, an application should use the Install method again.

ProductGUID:   ID of the proxy DLL.

A product GUID (also known as project ID) is used to distinguish among various installations performed by different applications.

ServerStartArguments:   The arguments to pass with the command.

Set this configuration setting before installing the native proxy DLL.

ServerStartCommandLine:   The command line to run when the server is not available.

This command is executed using the ShellExecute function of the Windows Shell API.

Set this configuration setting before installing the native proxy DLL.

ServerStartOperation:   The operation verb.

This command is executed using the ShellExecute function of the Windows Shell API. You may pass an optional operation verb to this function.

Set this configuration setting before installing the native proxy DLL.

ServerStartShowOption:   Defines how the application windows should be shown.

This value corresponds to the nShowCmd parameter of the ShellExecute function. The default value is 1 ("show normal").

Set this configuration setting before installing the native proxy DLL.

ServerStartTimeToWait:   Optional time to wait before retrying RPC connection.

The time is specified in milliseconds. The default value is 3000 (3 seconds). Set this configuration setting before installing the native proxy DLL.

ServerStartWorkingDirectory:   The working directory.

This path specifies a working directory for the started process.

Set this configuration setting before installing the native proxy DLL.

Base Config Settings

BuildInfo:   Information about the product's build.

When queried, this setting will return a string containing information about the product's build.

LicenseInfo:   Information about the current license.

When queried, this setting will return a string containing information about the license this instance of a class is using. It will return the following information:

  • Product: The product the license is for.
  • Product Key: The key the license was generated from.
  • License Source: Where the license was found (e.g., RuntimeLicense, License File).
  • License Type: The type of license installed (e.g., Royalty Free, Single Server).

Trappable Errors (ShellOverlays Class)

Error Handling (C++)

Call the GetLastErrorCode() method to obtain the last called method's result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. Known error codes are listed below. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.

ShellOverlays Errors

2    An item with given ID cannot be found. The CBFSSHELL_ERR_FILE_NOT_FOUND constant is provided for convenience and may be used in place of the numeric value.
20    Cannot load native proxy DLL. The CBFSSHELL_ERR_CANT_LOAD_PROXY constant is provided for convenience and may be used in place of the numeric value.
28    The major version of the proxy DLL doesn't match the major version of the .NET assembly. The CBFSSHELL_ERR_PROXY_VERSION_MISMATCH constant is provided for convenience and may be used in place of the numeric value.
38    End of data stream has been reached and no data could be read. The CBFSSHELL_ERR_STREAM_EOF constant is provided for convenience and may be used in place of the numeric value.
55    Proxy DLL not installed properly. The CBFSSHELL_ERR_NOT_INSTALLED constant is provided for convenience and may be used in place of the numeric value.
56    Installation of the native proxy DLL failed. The CBFSSHELL_ERR_INSTALL_FAILED constant is provided for convenience and may be used in place of the numeric value.
57    Uninstallation of the native proxy DLL failed. The CBFSSHELL_ERR_UNINSTALL_FAILED constant is provided for convenience and may be used in place of the numeric value.
58    Initialization of the native proxy DLL failed. The CBFSSHELL_ERR_INIT_FAILED constant is provided for convenience and may be used in place of the numeric value.
59    The current license and the ID in the native proxy DLL name don't match. The CBFSSHELL_ERR_PROXY_NAME_MISMATCH constant is provided for convenience and may be used in place of the numeric value.
60    Writing to the Windows registry failed. The CBFSSHELL_ERR_CANT_WRITE_TO_REGISTRY constant is provided for convenience and may be used in place of the numeric value.
61    This Menu instance has already been started. The CBFSSHELL_ERR_ALREADY_STARTED constant is provided for convenience and may be used in place of the numeric value.
62    A menu item with the same verb is already registered. The CBFSSHELL_ERR_MENU_ITEM_ALREADY_REG constant is provided for convenience and may be used in place of the numeric value.
63    No menu items have been registered. The CBFSSHELL_ERR_MENU_ITEM_NOT_REG constant is provided for convenience and may be used in place of the numeric value.
87    The passed parameter was not valid. The CBFSSHELL_ERR_INVALID_PARAMETER constant is provided for convenience and may be used in place of the numeric value.
122    The provided buffer is too small to accommodate all the data that must be placed in it. The CBFSSHELL_ERR_INSUFFICIENT_BUFFER constant is provided for convenience and may be used in place of the numeric value.