You cannot override the association like that.
The UserChoice
(and FileExts
) keys are undocumented and you should not write to them.
Because people force themselves and ignore the issue of "What if two programs did this?" Microsoft has made it increasingly difficult to programmatically set the default association for types/applications.
If you look inside a UserChoice
key on recent versions of Windows you will also see a Hash
value. If the ProgId
value does not match the hash Windows will ignore your attempt to take over the association. Only the ControlPanel/Settings UI can successfully change the association on these systems.
In enterprise environments you can use DISM/GPO. Applications installed by normal users cannot do this, your only option is to follow the Microsoft guidelines:
Register your association the normal documented way in HKEY_CLASSES_ROOT.
Additionally you can:
WinVista & Win7: You can force yourself by using the IApplicationAssociationRegistration
interface (Not recommended).
Win8: Ask the user if they want to change their associations and if they confirm you can call IApplicationAssociationRegistrationUI::LaunchAdvancedAssociationUI
.
Win10: Call IApplicationAssociationRegistrationUI::LaunchAdvancedAssociationUI
to display a help-popup instructing the user how they can change their associations.
LaunchAdvancedAssociationUI
can be used in NSIS v3+ like this:
!include LogicLib.nsh
!include Win\COM.nsh
Section
!insertmacro ComHlpr_CreateInProcInstance ${CLSID_ApplicationAssociationRegistrationUI} ${IID_IApplicationAssociationRegistrationUI} r0 ""
${If} $0 P<> 0
${IApplicationAssociationRegistrationUI::LaunchAdvancedAssociationUI} $0 '("Internet Explorer")' ; Replace with your registered application name
${IUnknown::Release} $0 ""
${EndIf}
SectionEnd