Adding an item to IE context menu

From NSIS Wiki

Author: beradrian (talk, contrib)


[edit] Description

These macros below add or remove items from the Internet Explorer context menu. You have to restart Internet Explorer in order to work. Tested only on Windows XP SP2.

[edit] How To Use

${IEMenuItem_Add} `Name` `Exec` `Contexts` `Flags`
Name
The title of the item as it appears on the context menu.
Exec
File, folder or web page to open when clicking the button. Accepts parameters.
Contexts
A logical OR of all the contexts where this item will appear.
Flags
If is 0x01 then executing this item will open a new window. Otherwise this is a silent command.
${IEMenuItem_Remove} `Name`
Name
The title of the item as it appears on the context menu, the same used with ${IEMenuItem_Add}.

[edit] The Macros

!define IE_CONTEXT_MENU_DEFAULT 0x1
!define IE_CONTEXT_MENU_IMAGE 0x2
!define IE_CONTEXT_MENU_CONTROL 0x4
!define IE_CONTEXT_MENU_TABLE 0x8
!define IE_CONTEXT_MENU_TEXTSELECT 0x10
!define IE_CONTEXT_MENU_ANCHOR 0x20
!define IE_CONTEXT_MENU_UNKNOWN 0x40
 
!define IEMenuItem_KeyName `SOFTWARE\Microsoft\Internet Explorer\MenuExt`
 
!define IEMenuItem_Add `!insertmacro IEMenuItem_Add`
!macro IEMenuItem_Add `Name` `Exec` `Contexts` `Flags`
    WriteRegStr HKCU `${IEMenuItem_KeyName}\${Name}` `` `${Exec}`
    WriteRegDWORD HKCU `${IEMenuItem_KeyName}\${Name}` `Contexts` ${Contexts}
    WriteRegDWORD HKCU `${IEMenuItem_KeyName}\${Name}` `Flags` ${Flags}
!macroend
 
!define IEMenuItem_Remove `!insertmacro IEMenuItem_Remove`
!macro IEMenuItem_Remove `Name`
    DeleteRegKey HKLM `${IEMenuItem_KeyName}\${Name}`
!macroend

Written by beradrian

Personal tools
donate