Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

195 lines
5.8 KiB

  1. #include "stock.h"
  2. #pragma hdrstop
  3. void SHPropertyBag_ReadStrDef(IPropertyBag* ppb, LPCWSTR pszPropName, LPWSTR psz, int cch, LPCWSTR pszDef)
  4. {
  5. if (FAILED(SHPropertyBag_ReadStr(ppb, pszPropName, psz, cch)))
  6. {
  7. if (pszDef)
  8. {
  9. StrCpyNW(psz, pszDef, cch);
  10. }
  11. else
  12. {
  13. StrCpyNW(psz, L"", cch);
  14. }
  15. }
  16. }
  17. void SHPropertyBag_ReadIntDef(IPropertyBag* ppb, LPCWSTR pszPropName, int* piResult, int iDef)
  18. {
  19. if (FAILED(SHPropertyBag_ReadInt(ppb, pszPropName, piResult)))
  20. {
  21. *piResult = iDef;
  22. }
  23. }
  24. void SHPropertyBag_ReadSHORTDef(IPropertyBag* ppb, LPCWSTR pszPropName, SHORT* psh, SHORT shDef)
  25. {
  26. if (FAILED(SHPropertyBag_ReadSHORT(ppb, pszPropName, psh)))
  27. {
  28. *psh = shDef;
  29. }
  30. }
  31. void SHPropertyBag_ReadLONGDef(IPropertyBag* ppb, LPCWSTR pszPropName, LONG* pl, LONG lDef)
  32. {
  33. if (FAILED(SHPropertyBag_ReadLONG(ppb, pszPropName, pl)))
  34. {
  35. *pl = lDef;
  36. }
  37. }
  38. void SHPropertyBag_ReadDWORDDef(IPropertyBag* ppb, LPCWSTR pszPropName, DWORD* pdw, DWORD dwDef)
  39. {
  40. if (FAILED(SHPropertyBag_ReadDWORD(ppb, pszPropName, pdw)))
  41. {
  42. *pdw = dwDef;
  43. }
  44. }
  45. void SHPropertyBag_ReadBOOLDef(IPropertyBag* ppb, LPCWSTR pszPropName, BOOL* pf, BOOL fDef)
  46. {
  47. if (FAILED(SHPropertyBag_ReadBOOL(ppb, pszPropName, pf)))
  48. {
  49. *pf = fDef;
  50. }
  51. }
  52. BOOL SHPropertyBag_ReadBOOLDefRet(IPropertyBag* ppb, LPCWSTR pszPropName, BOOL fDef)
  53. {
  54. BOOL fRet;
  55. SHPropertyBag_ReadBOOLDef(ppb, pszPropName, &fRet, fDef);
  56. return fRet;
  57. }
  58. void SHPropertyBag_ReadGUIDDef(IPropertyBag* ppb, LPCWSTR pszPropName, GUID* pguid, const GUID* pguidDef)
  59. {
  60. if (FAILED(SHPropertyBag_ReadGUID(ppb, pszPropName, pguid)))
  61. {
  62. *pguid = *pguidDef;
  63. }
  64. }
  65. void SHPropertyBag_ReadPOINTLDef(IPropertyBag* ppb, LPCWSTR pszPropName, POINTL* ppt, const POINTL* pptDef)
  66. {
  67. if (FAILED(SHPropertyBag_ReadPOINTL(ppb, pszPropName, ppt)))
  68. {
  69. *ppt = *pptDef;
  70. }
  71. }
  72. void SHPropertyBag_ReadPOINTSDef(IPropertyBag* ppb, LPCWSTR pszPropName, POINTS* ppt, const POINTS* pptDef)
  73. {
  74. if (FAILED(SHPropertyBag_ReadPOINTS(ppb, pszPropName, ppt)))
  75. {
  76. *ppt = *pptDef;
  77. }
  78. }
  79. void SHPropertyBag_ReadRECTLDef(IPropertyBag* ppb, LPCWSTR pszPropName, RECTL* prc, const RECTL* prcDef)
  80. {
  81. if (FAILED(SHPropertyBag_ReadRECTL(ppb, pszPropName, prc)))
  82. {
  83. *prc = *prcDef;
  84. }
  85. }
  86. void AppendScreenResString(const WCHAR* psz, WCHAR* pszBuff, ULONG cchBuff)
  87. {
  88. StrCpyNW(pszBuff, psz, cchBuff);
  89. ULONG cch = lstrlenW(pszBuff);
  90. SHGetPerScreenResName(pszBuff + cch, cchBuff- cch, 0);
  91. }
  92. HRESULT SHPropertyBag_ReadStreamScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, IStream** ppstm)
  93. {
  94. WCHAR szScreenResProp[128];
  95. AppendScreenResString(pszPropName, szScreenResProp, ARRAYSIZE(szScreenResProp));
  96. return SHPropertyBag_ReadStream(ppb, szScreenResProp, ppstm);
  97. }
  98. HRESULT SHPropertyBag_WriteStreamScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, IStream* pstm)
  99. {
  100. WCHAR szScreenResProp[128];
  101. AppendScreenResString(pszPropName, szScreenResProp, ARRAYSIZE(szScreenResProp));
  102. return SHPropertyBag_WriteStream(ppb, szScreenResProp, pstm);
  103. }
  104. HRESULT SHPropertyBag_ReadPOINTSScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, POINTS* ppt)
  105. {
  106. WCHAR szScreenResProp[128];
  107. AppendScreenResString(pszPropName, szScreenResProp, ARRAYSIZE(szScreenResProp));
  108. return SHPropertyBag_ReadPOINTS(ppb, szScreenResProp, ppt);
  109. }
  110. HRESULT SHPropertyBag_WritePOINTSScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, const POINTS* ppt)
  111. {
  112. WCHAR szScreenResProp[128];
  113. AppendScreenResString(pszPropName, szScreenResProp, ARRAYSIZE(szScreenResProp));
  114. return SHPropertyBag_WritePOINTS(ppb, szScreenResProp, ppt);
  115. }
  116. void SHPropertyBag_ReadDWORDScreenResDef(IPropertyBag* ppb, LPCWSTR pszPropName, DWORD* pdw, DWORD dw)
  117. {
  118. WCHAR szScreenResProp[128];
  119. AppendScreenResString(pszPropName, szScreenResProp, ARRAYSIZE(szScreenResProp));
  120. SHPropertyBag_ReadDWORDDef(ppb, szScreenResProp, pdw, dw);
  121. }
  122. HRESULT SHPropertyBag_WriteDWORDScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, const DWORD dw)
  123. {
  124. WCHAR szScreenResProp[128];
  125. AppendScreenResString(pszPropName, szScreenResProp, ARRAYSIZE(szScreenResProp));
  126. return SHPropertyBag_WriteDWORD(ppb, szScreenResProp, dw);
  127. }
  128. HRESULT SHPropertyBag_ReadPOINTLScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, POINTL* ppt)
  129. {
  130. WCHAR szScreenResProp[128];
  131. AppendScreenResString(pszPropName, szScreenResProp, ARRAYSIZE(szScreenResProp));
  132. return SHPropertyBag_ReadPOINTL(ppb, szScreenResProp, ppt);
  133. }
  134. HRESULT SHPropertyBag_WritePOINTLScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, const POINTL* ppt)
  135. {
  136. WCHAR szScreenResProp[128];
  137. AppendScreenResString(pszPropName, szScreenResProp, ARRAYSIZE(szScreenResProp));
  138. return SHPropertyBag_WritePOINTL(ppb, szScreenResProp, ppt);
  139. }
  140. HRESULT SHPropertyBag_ReadRECTLScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, RECTL* prc)
  141. {
  142. WCHAR szScreenResProp[128];
  143. AppendScreenResString(pszPropName, szScreenResProp, ARRAYSIZE(szScreenResProp));
  144. return SHPropertyBag_ReadRECTL(ppb, szScreenResProp, prc);
  145. }
  146. HRESULT SHPropertyBag_WriteRECTLScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName, const RECTL* prc)
  147. {
  148. WCHAR szScreenResProp[128];
  149. AppendScreenResString(pszPropName, szScreenResProp, ARRAYSIZE(szScreenResProp));
  150. return SHPropertyBag_WriteRECTL(ppb, szScreenResProp, prc);
  151. }
  152. HRESULT SHPropertyBag_DeleteScreenRes(IPropertyBag* ppb, LPCWSTR pszPropName)
  153. {
  154. WCHAR szScreenResProp[128];
  155. AppendScreenResString(pszPropName, szScreenResProp, ARRAYSIZE(szScreenResProp));
  156. return SHPropertyBag_Delete(ppb, szScreenResProp);
  157. }