Skip to content
tympanix edited this page Feb 18, 2019 · 8 revisions

Description

Programmatic Identifiers (ProgId) allows you to define the context menu and actions for one or more file types. Your application may have many of these installed into the registry if you require many different context menus for different file types.

More: Programmatic Identifiers

Example

The following example creates a programmatic identifier associated with the .appext file extension for an example application using Squirrel. Files with this extensions will have also have a file icon myicon.ico.

new ProgId({
    description: 'My Application File',
    friendlyAppName: true,
    squirrel: true,
    icon: 'myicon.ico',
    extensions: ['appext']
})

Options

description (string), optional

A string used to describe which file type the programmatic identifier will handle. Examples of this can be Music File, Text File, Image File.

appName (string), optional, default: app.getName()

The name of your application. When not specified this will default to the name of your Electron application. This is used in conjunction with the progExt to generate an unique ID for the programmatic identifier to register into the registry. It is advised to keep this to its default value.

progExt (string), optional

Used to create unique IDs for programmatic identifiers by appending it to the appName. Must be different for every programmatic identifier you register. The value should be something meaningful to the programmatic identifier you are about to create like: Text, Image or Archive. If your programmatic identifier only handles a single file type simply name this after the extension like: jpg, wav or dat. The ID is constructed like appName.progExt

More : ProgID

friendlyAppName, (string or bool), optional

Helping option which, when set, will default all ShellOptions in the shell property to have the friendlyAppName set. The property may be overwritten individually later. For more information see ShellOption

hive, (string), optional, default: Registry.HKCU

Used to change the hive in the windows registry in which the programmatic identifier is installed into. This defaults to the Registry.HKCUconstant from the winreg package corresponding to HKEY_CURRENT_USER. Changing the value to Registry.HKLM will install the programmatic identifier for the whole machine instead of a single user. This is however disadvised by windows guidelines why you should have a very good reason to change this.

squirrel, (bool), default: false

Helping property which, when set to true, will default all ShellOptions in the shell property to use Squirrel. If you are using Squirrel this is a set it and forget it option. For more information see ShellOption

icon, (string)

This will set the icon to use for files associated with the programmatic identifier. If the path is relative it will be relative to the path of your executable. The path can point to an .ico file, another .exe file to get the icon from or a .dll file (advanced). If this is not set, the icon for your application executable will be used to display file icons.

shell, (ShellOption array), default: [new ShellOption({})]

An array of the different actions in the context menu. This is shown when right clicking a file where this programmatic identifier is associated. See the documentation for ShellOption for more information. By default a single action will be displayed, namely the ShellOption without any options specified. This will show the classical Open context action.

extensions, (string array), default: []

An array of the file extensions associated with this programmatic identifier. The extensions are provided as strings without the leading period.

Functions

install(), returns: Promise

Installs the ProgId into the windows registry. Returns a promise whether the ProgId was successfully installed

uninstall(), returns: Promise

Uninstalls the ProgId from the windows registry. Returns a promise whether the ProgId was successfully uninstalled