Add !define for PKEY_AppUserModel_StartPinOption and use it in the COM.nsh example

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6295 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2013-03-12 23:23:01 +00:00
parent 9334c3fe89
commit 088c7ba872
2 changed files with 28 additions and 5 deletions

View file

@ -5,17 +5,34 @@
COM defines and helper macros
;Example:
; Example usage:
!include Win\COM.nsh
!include Win\Propkey.nsh
!insertmacro ComHlpr_CreateInProcInstance ${CLSID_ShellLink} ${IID_IShellLink} r0 ""
${If} $0 <> 0
${IShellLink::SetPath} $0 '("%COMSPEC%").r1'
${IShellLink::SetArguments} $0 '("/k echo HelloWorld").r2'
${If} $1 = 0
${AndIf} $2 = 0
${IUnknown::QueryInterface}$0 '("${IID_IPersistFile}",.r1)'
${IUnknown::QueryInterface} $0 '("${IID_IPropertyStore}",.r1)'
${If} $1 <> 0
${IPersistFile::Save} $1 '("$exedir\test.lnk",1)'
System::Call '*${SYSSTRUCT_PROPERTYKEY}(${PKEY_AppUserModel_StartPinOption})p.r2'
System::Call '*${SYSSTRUCT_PROPVARIANT}(${VT_UI4},,&i4 ${APPUSERMODEL_STARTPINOPTION_NOPINONINSTALL})p.r3'
${IPropertyStore::SetValue} $1 '($2,$3)'
; Reuse the PROPERTYKEY & PROPVARIANT buffers to set another property
System::Call '*$2${SYSSTRUCT_PROPERTYKEY}(${PKEY_AppUserModel_ExcludeFromShowInNewInstall})'
System::Call '*$3${SYSSTRUCT_PROPVARIANT}(${VT_BOOL},,&i2 ${VARIANT_TRUE})'
${IPropertyStore::SetValue} $1 '($2,$3)'
System::Free $2
System::Free $3
${IPropertyStore::Commit} $1 ""
${IUnknown::Release} $1 ""
${EndIf}
${IUnknown::QueryInterface} $0 '("${IID_IPersistFile}",.r1)'
${If} $1 <> 0
${IPersistFile::Save} $1 '("$SMPrograms\nsis_test.lnk",1)'
${IUnknown::Release} $1 ""
${EndIf}
${EndIf}

View file

@ -22,6 +22,9 @@ WTypes.h
!define VT_LPSTR 30
!define VT_LPWSTR 31
!define /ifndef VARIANT_TRUE -1
!define /ifndef VARIANT_FALSE 0
!define SYSSIZEOF_PROPERTYKEY 20
!define SYSSTRUCT_PROPERTYKEY (&g16,&i4) ;System.dll is buggy when it comes to g and forces us to specify the size
@ -37,8 +40,11 @@ PropIdl.h
Propkey.h
**************************************************/
!define PKEY_AppUserModel_ID '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",5'
!define PKEY_AppUserModel_ExcludeFromShowInNewInstall '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",8'
!define PKEY_AppUserModel_PreventPinning '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",9'
!define PKEY_AppUserModel_ExcludeFromShowInNewInstall '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",8' ; VT_BOOL
!define PKEY_AppUserModel_PreventPinning '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",9' ; VT_BOOL
!define APPUSERMODEL_STARTPINOPTION_NOPINONINSTALL 1
!define APPUSERMODEL_STARTPINOPTION_USERPINNED 2
!define PKEY_AppUserModel_StartPinOption '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",12' ; VT_UI4 [Eight+]
!verbose pop