Propkey.nsh 8.1 KB

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