| 1 |
!ifndef __WIN_PROPKEY__INC |
| 2 |
!define __WIN_PROPKEY__INC |
| 3 |
!verbose push |
| 4 |
!verbose 3 |
| 5 |
|
| 6 |
|
| 7 |
/************************************************** |
| 8 |
WTypes.h |
| 9 |
**************************************************/ |
| 10 |
;NOTE: This list is incomplete |
| 11 |
!define VT_EMPTY 0 |
| 12 |
!define VT_NULL 1 |
| 13 |
!define VT_I2 2 |
| 14 |
!define VT_I4 3 |
| 15 |
!define VT_BSTR 8 |
| 16 |
!define VT_BOOL 11 |
| 17 |
!define VT_I1 16 |
| 18 |
!define VT_UI1 17 |
| 19 |
!define VT_UI2 18 |
| 20 |
!define VT_UI4 19 |
| 21 |
!define VT_I8 20 |
| 22 |
!define VT_UI8 21 |
| 23 |
!define VT_INT 22 |
| 24 |
!define VT_UINT 23 |
| 25 |
!define VT_HRESULT 25 |
| 26 |
!define VT_PTR 26 |
| 27 |
!define VT_SAFEARRAY 27 |
| 28 |
!define VT_LPSTR 30 ; SHStrDupA |
| 29 |
!define VT_LPWSTR 31 ; SHStrDupW |
| 30 |
!define VT_FILETIME 64 |
| 31 |
!define VT_STREAM 66 |
| 32 |
!define VT_CLSID 72 ; Pointer to CoTaskMem allocated GUID |
| 33 |
!define VT_TYPEMASK 0xFFF |
| 34 |
!define VT_VECTOR 0x1000 |
| 35 |
!define VT_ARRAY 0x2000 |
| 36 |
!define VT_BYREF 0x4000 |
| 37 |
|
| 38 |
!define /ifndef VARIANT_TRUE -1 |
| 39 |
!define /ifndef VARIANT_FALSE 0 |
| 40 |
|
| 41 |
!define SYSSIZEOF_PROPERTYKEY 20 |
| 42 |
!define SYSSTRUCT_PROPERTYKEY (&g16,&i4) ;System.dll is buggy when it comes to g and forces us to specify the size |
| 43 |
|
| 44 |
!define STGC_DEFAULT 0 |
| 45 |
!define STGC_OVERWRITE 1 |
| 46 |
!define STGC_ONLYIFCURRENT 2 |
| 47 |
!define STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE 4 |
| 48 |
!define STGC_CONSOLIDATE 8 |
| 49 |
|
| 50 |
|
| 51 |
/************************************************** |
| 52 |
OAIdl.h |
| 53 |
**************************************************/ |
| 54 |
!if "${NSIS_PTR_SIZE}" > 4 |
| 55 |
!define SYSSIZEOF_VARIANT 24 |
| 56 |
!define SYSSTRUCT_VARIANT (&i2,&i6,&i8,&i8) |
| 57 |
!else |
| 58 |
!define SYSSIZEOF_VARIANT 16 |
| 59 |
!define SYSSTRUCT_VARIANT (&i2,&i6,&i8) |
| 60 |
!endif |
| 61 |
|
| 62 |
|
| 63 |
/************************************************** |
| 64 |
PropIdl.h |
| 65 |
**************************************************/ |
| 66 |
!if "${NSIS_PTR_SIZE}" > 4 |
| 67 |
!define SYSSIZEOF_PROPVARIANT 24 |
| 68 |
!define SYSSTRUCT_PROPVARIANT (&i2,&i6,&i8,&i8) |
| 69 |
!else |
| 70 |
!define SYSSIZEOF_PROPVARIANT 16 |
| 71 |
!define SYSSTRUCT_PROPVARIANT (&i2,&i6,&i8) |
| 72 |
!endif |
| 73 |
|
| 74 |
!define PRSPEC_LPWSTR 0 |
| 75 |
!define PRSPEC_PROPID 1 |
| 76 |
!define SYSSTRUCT_PROPSPEC (p,p) |
| 77 |
|
| 78 |
|
| 79 |
/************************************************** |
| 80 |
Propkey.h |
| 81 |
**************************************************/ |
| 82 |
!define PKEY_AppUserModel_RelaunchCommand '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",2' ; VT_LPWSTR (SHGetPropertyStoreForWindow) |
| 83 |
!define PKEY_AppUserModel_RelaunchIconResource '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",3' ; VT_LPWSTR (SHGetPropertyStoreForWindow, optional. Path to icon or module, with resource ID or index.) |
| 84 |
!define PKEY_AppUserModel_RelaunchDisplayNameResource '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",4' ; VT_LPWSTR (SHGetPropertyStoreForWindow. @ style indirect resource string or a plain string.) |
| 85 |
!define PKEY_AppUserModel_ID '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",5' ; VT_LPWSTR |
| 86 |
!define PKEY_AppUserModel_IsDestListSeparator '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",6' ; VT_BOOL |
| 87 |
!define PKEY_AppUserModel_ExcludeFromShowInNewInstall '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",8' ; VT_BOOL |
| 88 |
!define PKEY_AppUserModel_PreventPinning '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",9' ; VT_BOOL |
| 89 |
!define PKEY_AppUserModel_IsDualMode '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",11' ; [Eight+] VT_BOOL |
| 90 |
!define APPUSERMODEL_STARTPINOPTION_NOPINONINSTALL 1 |
| 91 |
!define APPUSERMODEL_STARTPINOPTION_USERPINNED 2 |
| 92 |
!define PKEY_AppUserModel_StartPinOption '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",12' ; [Eight+] VT_UI4 |
| 93 |
!define PKEY_AppUserModel_ToastActivatorCLSID '"{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}",26' ; [10FU1507+] VT_CLSID |
| 94 |
!define PKEY_EdgeGesture_DisableTouchWhenFullscreen '"{32CE38B2-2C9A-41B1-9BC5-B3784394AA44}",2' ; [Eight+] VT_BOOL (SHGetPropertyStoreForWindow) |
| 95 |
|
| 96 |
|
| 97 |
/************************************************** |
| 98 |
ShlGuid.h & ShlObj.h |
| 99 |
**************************************************/ |
| 100 |
!define FMTID_Intshcut {000214A0-0000-0000-C000-000000000046} |
| 101 |
!define PID_IS_URL 2 ; VT_LPWSTR |
| 102 |
!define PID_IS_HOTKEY 6 ; VT_UI2 |
| 103 |
!define PID_IS_ICONINDEX 8 ; VT_I4 |
| 104 |
!define PID_IS_ICONFILE 9 ; VT_LPWSTR |
| 105 |
!define PKEY_Intshcut_Url '"${FMTID_Intshcut}",${PID_IS_URL}' ; Undocumented |
| 106 |
!define FMTID_InternetSite {000214A1-0000-0000-C000-000000000046} |
| 107 |
!define PID_INTSITE_LASTVISIT 4 ; VT_FILETIME |
| 108 |
!define PID_INTSITE_VISITCOUNT 6 ; VT_UI4 |
| 109 |
|
| 110 |
|
| 111 |
/************************************************** |
| 112 |
Helper macros |
| 113 |
**************************************************/ |
| 114 |
!define V_GetVT '!insertmacro V_GetVT ' |
| 115 |
!macro V_GetVT pPV sysdst |
| 116 |
System::Call '*${pPV}(&i2.${sysdst})' |
| 117 |
!macroend |
| 118 |
!define V_SetVT '!insertmacro V_SetVT ' |
| 119 |
!macro V_SetVT pPV syssrc |
| 120 |
System::Call '*${pPV}(&i2 ${syssrc})' |
| 121 |
!macroend |
| 122 |
!macro V_GetHelper sysvaltyp pPV sysdst |
| 123 |
System::Call '*${pPV}(l,${sysvaltyp}.${sysdst})' |
| 124 |
!macroend |
| 125 |
!macro V_GenericSetHelper sysvaltyp pPV VT syssrc |
| 126 |
!if "${VT}" != "" ; Setting the VT is optional |
| 127 |
System::Call '*${pPV}(&i2 ${VT},&i6,${sysvaltyp}${syssrc})' |
| 128 |
!else |
| 129 |
System::Call '*${pPV}(l,${sysvaltyp}${syssrc})' |
| 130 |
!endif |
| 131 |
!macroend |
| 132 |
!macro V_SpecificSetHelper VT sysvaltyp pPV syssrc |
| 133 |
System::Call '*${pPV}(&i2 ${VT},&i6,${sysvaltyp}${syssrc})' |
| 134 |
!macroend |
| 135 |
!macro Make_V_GetterSetter name sysvaltyp setsep |
| 136 |
!define V_Get${name} '!insertmacro V_GetHelper "${sysvaltyp}" ' |
| 137 |
!ifdef VT_${name} |
| 138 |
!define V_Set${name} '!insertmacro V_SpecificSetHelper ${VT_${name}} "${sysvaltyp}${setsep}" ' |
| 139 |
!else |
| 140 |
!define V_Set${name} '!insertmacro V_GenericSetHelper "${sysvaltyp}${setsep}" ' |
| 141 |
!endif |
| 142 |
!macroend |
| 143 |
!insertmacro Make_V_GetterSetter Int8 "&i1" " " ; Generic |
| 144 |
!insertmacro Make_V_GetterSetter Int16 "&i2" " " ; Generic |
| 145 |
!insertmacro Make_V_GetterSetter Int32 "i" "" ; Generic |
| 146 |
!insertmacro Make_V_GetterSetter Int64 "l" "" ; Generic |
| 147 |
!insertmacro Make_V_GetterSetter Pointer "p" "" ; Generic |
| 148 |
!insertmacro Make_V_GetterSetter I4 "i" " " |
| 149 |
!insertmacro Make_V_GetterSetter BOOL "&i2" " " |
| 150 |
!insertmacro Make_V_GetterSetter FILETIME "l" "" |
| 151 |
|
| 152 |
!macro VariantInit pV |
| 153 |
${V_SetVT} ${pV} ${VT_EMPTY} |
| 154 |
!macroend |
| 155 |
!macro VariantClear pV |
| 156 |
System::Call 'OLEAUT32::#9(p${pV})' |
| 157 |
!macroend |
| 158 |
!macro VariantCopy pDstV pSrcV sysretHR |
| 159 |
System::Call 'OLEAUT32::#10(p${pDstV},p${pSrcV})i.${sysretHR}' ; (Frees the destination variant before it copies the source) |
| 160 |
!macroend |
| 161 |
!macro VariantCopyInd pDstV pSrcV sysretHR |
| 162 |
System::Call 'OLEAUT32::#11(p${pDstV},p${pSrcV})i.${sysretHR}' ; (Frees the destination variant before it copies the source) |
| 163 |
!macroend |
| 164 |
!macro VariantChangeType pDstV pSrcV Flags VT sysretHR |
| 165 |
System::Call 'OLEAUT32::#12(p${pDstV},p${pSrcV},i${Flags},i${VT})i.${sysretHR}' ; (Might free the destination on success) |
| 166 |
!macroend |
| 167 |
|
| 168 |
|
| 169 |
!macro PropVariantClear pPV |
| 170 |
System::Call 'OLE32::PropVariantClear(p${pPV})' ; WinNT4.SP0+, Win98+, IE4+ |
| 171 |
!macroend |
| 172 |
!macro PropVariantCopy pDstPV pSrcPV sysretHR |
| 173 |
System::Call 'OLE32::PropVariantCopy(p${pDstPV},p${pSrcPV})i.${sysretHR}' ; WinNT4.SP0+, Win98+, IE4+ (Does NOT free the destination before it copies the source) |
| 174 |
!macroend |
| 175 |
!macro PropVariantChangeType pDstPV pSrcPV VT sysretHR |
| 176 |
!ifdef NSIS_ARM | NSIS_ARM32 | NSIS_ARMNT | NSIS_ARM64 |
| 177 |
System::Call 'PROPSYS::PropVariantChangeType(p${pDstPV},p${pSrcPV},i0,i${VT})i.${sysretHR}' |
| 178 |
!else |
| 179 |
Push "${VT}" |
| 180 |
Push ${pSrcPV} |
| 181 |
Push ${pDstPV} |
| 182 |
!include Util.nsh |
| 183 |
${CallArtificialFunction} TryPropVariantChangeType |
| 184 |
System::Call 'KERNEL32::SetLastError(is${sysretHR})' ; A hack to move the result from the stack to somewhere with System variable syntax |
| 185 |
!endif |
| 186 |
!macroend |
| 187 |
!macro TryPropVariantChangeType |
| 188 |
System::Store S |
| 189 |
System::Call 'PROPSYS::PropVariantChangeType(psr1,psr2,i0,isr3)i.r0' ; Vista+ (Source and destination cannot be the same address) |
| 190 |
StrCmp $0 error "" done |
| 191 |
System::Call 'OLE32::PropVariantChangeType(pr1,pr2,i0,i0,ir3})i.r0' ; 2000+ (Source and destination cannot be the same address) |
| 192 |
!if ${NSIS_PTR_SIZE} < 8 |
| 193 |
StrCmp $0 error "" done |
| 194 |
!insertmacro VariantChangeType $1 $2 0 $3 r0 ; This is not really correct but there is no PROPVARIANT support on these platforms. Might free the destination! |
| 195 |
!endif |
| 196 |
done: |
| 197 |
Push $0 |
| 198 |
System::Store L |
| 199 |
!macroend |
| 200 |
|
| 201 |
|
| 202 |
!macro IPropertyStorage_ReadPropById pPS ID pPV sysoutHR |
| 203 |
System::Call '*(p${PRSPEC_PROPID},p${ID})p.s' |
| 204 |
${IPropertyStorage::ReadMultiple} ${pPS} '(1,pss,p${pPV})${sysoutHR}' |
| 205 |
System::Free |
| 206 |
!macroend |
| 207 |
|
| 208 |
!macro IPropertyStorage_WritePropById pPS ID pPV sysoutHR |
| 209 |
System::Call '*(p${PRSPEC_PROPID},p${ID})p.s' |
| 210 |
${IPropertyStorage::WriteMultiple} ${pPS} '(1,pss,p${pPV},2)${sysoutHR}' |
| 211 |
System::Free |
| 212 |
!macroend |
| 213 |
|
| 214 |
|
| 215 |
!verbose pop |
| 216 |
!endif /* __WIN_PROPKEY__INC */ |