From 088c7ba872a5945b4deff2a48de16e3e5d099173 Mon Sep 17 00:00:00 2001 From: anders_k Date: Tue, 12 Mar 2013 23:23:01 +0000 Subject: [PATCH] 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 --- Include/Win/COM.nsh | 23 ++++++++++++++++++++--- Include/Win/Propkey.nsh | 10 ++++++++-- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Include/Win/COM.nsh b/Include/Win/COM.nsh index 71a50822..8f8a9f81 100644 --- a/Include/Win/COM.nsh +++ b/Include/Win/COM.nsh @@ -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} diff --git a/Include/Win/Propkey.nsh b/Include/Win/Propkey.nsh index a799f20f..c7e553d9 100644 --- a/Include/Win/Propkey.nsh +++ b/Include/Win/Propkey.nsh @@ -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