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.

448 lines
20 KiB

  1. #ifndef _IEAKUTIL_H_
  2. #define _IEAKUTIL_H_
  3. #include <delayimp.h>
  4. #include "dload.h"
  5. #include "debug.h"
  6. /////////////////////////////////////////////////////////////////////////////
  7. // Required definitions in the final project
  8. extern TCHAR g_szModule[];
  9. extern HANDLE g_hBaseDllHandle;
  10. extern const DLOAD_DLL_MAP g_DllMap;
  11. /////////////////////////////////////////////////////////////////////////////
  12. // Macros
  13. #ifndef ARRAYSIZE
  14. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
  15. #endif
  16. #ifndef countof
  17. #define countof ARRAYSIZE
  18. #endif
  19. #define IE3_VERSION 1086
  20. /////////////////////////////////////////////////////////////////////////////
  21. // Classes
  22. #include "newcur.h"
  23. #include "logitem.h"
  24. #include "regins.h"
  25. /////////////////////////////////////////////////////////////////////////////
  26. // Unicode wrappers
  27. #include "unicwrap.h"
  28. /////////////////////////////////////////////////////////////////////////////
  29. // Functions
  30. //----- Dialog Controls Routines -----
  31. #define EnableDBCSChars(hDlg, iCtrlID) (InitSysFont((hDlg), (iCtrlID)))
  32. #define DisableDBCSChars(hDlg, iCtrlID) (ImmAssociateContext(GetDlgItem((hDlg), (iCtrlID)), NULL))
  33. void InitSysFont(HWND hDlg, int iCtrlID);
  34. UINT GetRadioButton(HWND hDlg, UINT idFirst, UINT idLast);
  35. #define EnableDlgItem(hDlg, idCtrl) (EnableWindow(GetDlgItem((hDlg), (idCtrl)), TRUE))
  36. #define ShowDlgItem(hDlg, idCtrl) (ShowWindow(GetDlgItem((hDlg), (idCtrl)), SW_SHOW))
  37. #define EnableDlgItem2(hDlg, idCtrl, fEnable) (EnableWindow(GetDlgItem((hDlg), (idCtrl)), (fEnable)))
  38. #define ShowDlgItem2(hDlg, idCtrl, fShow) (ShowWindow(GetDlgItem((hDlg), (idCtrl)), (fShow) ? SW_SHOW : SW_HIDE))
  39. #define DisableDlgItem(hDlg, idCtrl) (EnableWindow(GetDlgItem((hDlg), (idCtrl)), FALSE))
  40. #define HideDlgItem(hDlg, idCtrl) (ShowWindow(GetDlgItem((hDlg), (idCtrl)), SW_HIDE))
  41. BOOL EnableDlgItems(HWND hDlg, const PINT pidCtrls, UINT cidCtrls, BOOL fEnable = TRUE);
  42. #define DisableDlgItems(hDlg, pidCtrls, cidCtrls) (EnableDlgItems((hDlg), (pidCtrls), (cidCtrls), FALSE))
  43. #define IsDlgItemEnabled(hDlg, idCtrl) (IsWindowEnabled(GetDlgItem((hDlg), (idCtrl))))
  44. #define GetDlgItemTextLength(hDlg, idCtrl) (GetWindowTextLength(GetDlgItem((hDlg), (idCtrl))))
  45. BOOL SetDlgItemFocus(HWND hDlg, int iCtrlID, BOOL fUsePropertySheet = FALSE);
  46. BOOL EnsureDialogFocus(HWND hDlg, int idFocus, int idBackup, BOOL fUsePropertySheet = FALSE);
  47. BOOL EnsureDialogFocus(HWND hDlg, const PINT pidFocus, UINT cidFocus, int idBackup, BOOL fUsePropertySheet = FALSE);
  48. void SetDlgItemTextTriState(HWND hDlg, int nIDDlgText, int nIDDlgCheck, PCTSTR pszString, BOOL fChecked);
  49. BOOL GetDlgItemTextTriState(HWND hDlg, int nIDDlgText, int nIDDlgCheck, PTSTR pszString, int nMaxCount);
  50. #define TS_CHECK_OK 1
  51. #define TS_CHECK_ERROR 2
  52. #define TS_CHECK_SKIP 3
  53. void IsTriStateValid(HWND hDlg, int nIDDlgText, int nIDDlgCheck, PINT pnStatus, PCTSTR pszErrMsg, PCTSTR pszTitle);
  54. //----- String Routines -----
  55. int StrPrepend(PTSTR pszSource, UINT cchSource, PCTSTR pszAdd, UINT cchAdd = 0);
  56. #define StrRemoveWhitespace(pszSrc) (StrTrim((pszSrc), TEXT(" \t\r\n")))
  57. void StrRemoveAllWhiteSpace(PTSTR pszBuf);
  58. #define StrLenA(pszSrcA) (lstrlenA(pszSrcA))
  59. #define StrLenW(pszSrcW) (lstrlenW(pszSrcW))
  60. #define StrLenUAW(pszSrcUAW) (ualstrlenW(pszSrcUAW))
  61. #define StrCbFromCchA(cchSrc) (cchSrc)
  62. #define StrCbFromCchW(cchSrc) ((cchSrc) * sizeof(WCHAR))
  63. #define StrCchFromCbA(cbSrc) (cbSrc)
  64. #define StrCchFromCbW(cbSrc) (GetUnitsFromCb(cbSrc, sizeof(WCHAR)))
  65. #define StrCbFromSzA(pszSrcA) ((pszSrcA) != NULL ? StrCbFromCchA(StrLenA(pszSrcA) + 1) : 0)
  66. #define StrCbFromSzW(pszSrcW) ((pszSrcW) != NULL ? StrCbFromCchW(StrLenW(pszSrcW) + 1) : 0)
  67. #define StrCbFromSzUAW(pszSrcUAW) ((pszSrcUAW) != NULL ? StrCbFromCchW(StrLenUAW(pszSrcUAW) + 1) : 0)
  68. #ifdef _UNICODE
  69. #define StrLen StrLenW
  70. #define StrCbFromCch StrCbFromCchW
  71. #define StrCbFromSz StrCbFromSzW
  72. #define StrCchFromCb StrCchFromCbW
  73. #define StrCbFromSzUA StrCbFromSzUAW
  74. #else
  75. #define StrLen StrLenA
  76. #define StrCbFromCch StrCbFromCchA
  77. #define StrCbFromSz StrCbFromSzA
  78. #define StrCchFromCb StrCchFromCbA
  79. #define StrCbFromSzUA StrCbFromSzA
  80. #endif
  81. #define REMOVE_QUOTES 0x01
  82. #define IGNORE_QUOTES 0x02
  83. PTSTR StrGetNextField(PTSTR *ppszData, PCTSTR pcszDelims, DWORD dwFlags);
  84. PTSTR WINAPIV FormatString(PCTSTR pcszFormatString, ...);
  85. #define ISNULL(sz) ((*(sz)) == TEXT('\0'))
  86. #define ISNONNULL(sz) ((*(sz)) != TEXT('\0'))
  87. //----- String Conversion Routines -----
  88. PWSTR StrAnsiToUnicode(PWSTR pszTarget, PCSTR pszSource, UINT cchTarget = 0);
  89. PSTR StrUnicodeToAnsi(PSTR pszTarget, PCWSTR pszSource, UINT cchTarget = 0);
  90. PTSTR StrSameToSame (PTSTR pszTarget, PCTSTR pszSource, UINT cchTarget = 0);
  91. #ifndef ATLA2WHELPER
  92. #define ATLA2WHELPER StrAnsiToUnicode
  93. #define ATLW2AHELPER StrUnicodeToAnsi
  94. #include <atlconv.h>
  95. #endif
  96. #if (_ATL_VER != 0x0202)
  97. #pragma message("WARNING: (andrewgu) _ATL_VER changed! please update this file.")
  98. #endif
  99. #ifdef USES_CONVERSION
  100. #undef USES_CONVERSION
  101. #endif
  102. #define USES_CONVERSION int _convert; _convert = 0
  103. #define A2Wbuf(pszSource, pszTarget, cchTarget) StrAnsiToUnicode((pszTarget), (pszSource), (cchTarget))
  104. #define A2Wbux(pszSource, pszTarget) StrAnsiToUnicode((pszTarget), (pszSource))
  105. #define W2Abuf(pszSource, pszTarget, cchTarget) StrUnicodeToAnsi((pszTarget), (pszSource), (cchTarget))
  106. #define W2Abux(pszSource, pszTarget) StrUnicodeToAnsi((pszTarget), (pszSource))
  107. #ifdef _UNICODE
  108. #define T2Abuf W2Abuf
  109. #define T2Abux W2Abux
  110. #define A2Tbuf A2Wbuf
  111. #define A2Tbux A2Wbux
  112. #define T2Wbuf(pszSource, pszTarget, cchTarget) StrSameToSame((pszTarget), (pszSource), (cchTarget))
  113. #define T2Wbux(pszSource, pszTarget) StrSameToSame((pszTarget), (pszSource))
  114. #define W2Tbuf(pszSource, pszTarget, cchTarget) StrSameToSame((pszTarget), (pszSource), (cchTarget))
  115. #define W2Tbux(pszSource, pszTarget) StrSameToSame((pszTarget), (pszSource))
  116. #else /* #ifndef _UNICODE */
  117. #define T2Abuf(pszSource, pszTarget, cchTarget) StrSameToSame((pszTarget), (pszSource), (cchTarget))
  118. #define T2Abux(pszSource, pszTarget) StrSameToSame((pszTarget), (pszSource))
  119. #define A2Tbuf(pszSource, pszTarget, cchTarget) StrSameToSame((pszTarget), (pszSource), (cchTarget))
  120. #define A2Tbux(pszSource, pszTarget) StrSameToSame((pszTarget), (pszSource))
  121. #define T2Wbuf A2Wbuf
  122. #define T2Wbux A2Wbux
  123. #define W2Tbuf W2Abuf
  124. #define W2Tbux W2Abux
  125. #endif /* #ifdef _UNICODE */
  126. //----- Path Routines -----
  127. BOOL PathCreatePath(PCTSTR pszPathToCreate);
  128. #define PIVP_DEFAULT 0x00000000
  129. #define PIVP_FILENAME_ONLY 0x00000001
  130. #define PIVP_RELATIVE_VALID 0x00000002
  131. #define PIVP_DBCS_INVALID 0x00000004
  132. #define PIVP_0x5C_INVALID 0x00000008
  133. #define PIVP_MUST_EXIST 0x00000010
  134. #define PIVP_FILE_ONLY (PIVP_MUST_EXIST | 0x00000020)
  135. #define PIVP_FOLDER_ONLY (PIVP_MUST_EXIST | 0x00000040)
  136. #define PIVP_EXCHAR_INVALID (PIVP_DBCS_INVALID | 0x00000080)
  137. BOOL PathIsValidPath(PCTSTR pszPath, DWORD dwFlags = PIVP_DEFAULT);
  138. BOOL PathIsValidFile(PCTSTR pszFile, DWORD dwFlags = PIVP_DEFAULT);
  139. #define PIVP_VALID 0x00000000 // the path is valid
  140. #define PIVP_INVALID 0x80000000 // general flag for failure
  141. #define PIVP_ARG 0x80000001 // invalid argument to the function
  142. #define PIVP_CHAR 0x80000002 // invalid char
  143. #define PIVP_WILD 0x80000004 // wildcard
  144. #define PIVP_RELATIVE 0x80000008 // "\\foo" if PIVP_RELATIVE_VALID is not set
  145. #define PIVP_FIRST_CHAR 0x80000010 // "<not '\\' | ' ' | not <LFN char>>\\foo"
  146. #define PIVP_PRESLASH 0x80000020 // char in front of '\\' is invalid
  147. #define PIVP_SPACE 0x80000040 // "bar \\foo"
  148. #define PIVP_FWDSLASH 0x80000080 // '/' encountered
  149. #define PIVP_COLON 0x80000100 // ':' in other than "c:" position
  150. #define PIVP_DRIVE 0x80000200 // invalid drive letter
  151. #define PIVP_SEPARATOR 0x80000400 // invalid separator, should never happen
  152. #define PIVP_DBCS 0x80000800 // DBCS encountered when PIVP_DBCS_INVALID is set
  153. #define PIVP_0x5C 0x80001000 // 0x5C encountered when PIVP_0x5C_INVALID is set
  154. #define PIVP_DOESNT_EXIST 0x80002000 // the path or file doesn't exist
  155. #define PIVP_NOT_FILE 0x80004000 // not a file when PIVP_FILE_ONLY is set
  156. #define PIVP_NOT_FOLDER 0x80008000 // not a folder when PIVP_FOLDER_ONLY is set
  157. #define PIVP_EXCHAR 0x80010000 // extended char encountered when PIVP_EXCHAR_INVALID is set
  158. DWORD PathIsValidPathEx(PCTSTR pszPath, DWORD dwFlags = PIVP_DEFAULT, PCTSTR *ppszError = NULL);
  159. #define PEP_DEFAULT 0x00000000
  160. #define PEP_SCPE_DEFAULT 0x00000000
  161. #define PEP_SCPE_NOFILES 0x00000001
  162. #define PEP_SCPE_NOFOLDERS 0x00000002
  163. #define PEP_SCPE_ALL 0x00000003
  164. #define PEP_CTRL_DEFAULT 0x00000000
  165. #define PEP_CTRL_ENUMPROCFIRST 0x00000010
  166. #define PEP_CTRL_NOSECONDCALL 0x00000020
  167. #define PEP_CTRL_USECONTROL 0x00000040
  168. #define PEP_CTRL_RESET 0x00000080
  169. #define PEP_CTRL_KEEPAPPLY 0x00000100
  170. #define PEP_CTRL_ALL 0x000001F0
  171. #define PEP_RCRS_DEFAULT 0x00000000
  172. #define PEP_RCRS_FALSE 0x00010000
  173. #define PEP_RCRS_CONTINUE 0x00020000
  174. #define PEP_RCRS_CONTINUE_FALSE 0x00040000
  175. #define PEP_RCRS_FAILED 0x00080000
  176. #define PEP_RCRS_ALL 0x000F0000
  177. #define PEP_S_CONTINUE ((HRESULT)0x00000002L)
  178. #define PEP_S_CONTINUE_FALSE ((HRESULT)0x00000003L)
  179. #define PEP_ENUM_INPOS_FIRST 0
  180. #define PEP_ENUM_INPOS_FLAGS 0
  181. #define PEP_ENUM_INPOS_RECOURSEFLAGS 1
  182. #define PEP_ENUM_INPOS_LAST 2
  183. #define PEP_ENUM_OUTPOS_FIRST 0
  184. #define PEP_ENUM_OUTPOS_SECONDCALL 0
  185. #define PEP_ENUM_OUTPOS_BELOW 1
  186. #define PEP_ENUM_OUTPOS_THISLEVEL 2
  187. #define PEP_ENUM_OUTPOS_ABOVE_SIBLINGS 3
  188. #define PEP_ENUM_OUTPOS_ABOVE 4
  189. #define PEP_ENUM_OUTPOS_LAST 5
  190. #define PEP_RCRS_OUTPOS_FIRST 0
  191. #define PEP_RCRS_OUTPOS_SECONDCALL 0
  192. #define PEP_RCRS_OUTPOS_BELOW 1
  193. #define PEP_RCRS_OUTPOS_THISLEVEL 2
  194. #define PEP_RCRS_OUTPOS_LAST 3
  195. typedef HRESULT (*PFNPATHENUMPATHPROC)(PCTSTR pszPath, PWIN32_FIND_DATA pfd, LPARAM lParam,
  196. PDWORD *prgdwControl /*= NULL*/);
  197. HRESULT PathEnumeratePath(PCTSTR pszPath, DWORD dwFlags, PFNPATHENUMPATHPROC pfnEnumProc, LPARAM lParam,
  198. PDWORD *ppdwReserved = NULL);
  199. BOOL PathRemovePath(PCTSTR pcszPath, DWORD dwFlags = 0);
  200. BOOL PathIsLocalPath(PCTSTR pszPath);
  201. BOOL PathFileExistsInDir(PCTSTR pcszFile, PCTSTR pcszDir);
  202. BOOL PathHasBackslash(PCTSTR pcszPath);
  203. #define PathIsExtension(pszFile, pszExt) (StrCmpI(PathFindExtension(pszFile), pszExt) == 0)
  204. #define PathIsFullPath(pszFile) (StrCmpI(PathFindFileName(pszFile), pszFile) != 0)
  205. #define PathIsFileURL(pszUrl) (StrCmpNI(pszUrl, FILEPREFIX, countof(FILEPREFIX)-1) == 0)
  206. #define PathIsFileOrFileURL(pszUrl) (PathFileExists(pszUrl) || PathIsFileURL(pszUrl))
  207. #define FILES_ONLY 0x00000001
  208. #define FILES_AND_DIRS 0x00000002
  209. BOOL PathIsEmptyPath(PCTSTR pcszPath, DWORD dwFlags = FILES_AND_DIRS, PCTSTR pcszExcludeFile = NULL);
  210. void PathReplaceWithLDIDs(PTSTR pszPath);
  211. //----- Registry Routines -----
  212. #define SHCreateKey(hk, pszSubKey, sam, phkResult) \
  213. (RegCreateKeyEx((hk), (pszSubKey), 0, NULL, REG_OPTION_NON_VOLATILE, (sam), NULL, (phkResult), NULL))
  214. #define SHCreateKeyHKCR(pszSubKey, sam, phkResult) \
  215. (SHCreateKey(HKEY_CLASSES_ROOT, pszSubKey, sam, phkResult))
  216. #define SHCreateKeyHKCC(pszSubKey, sam, phkResult) \
  217. (SHCreateKey(HKEY_CURRENT_CONFIG, pszSubKey, sam, phkResult))
  218. #define SHCreateKeyHKLM(pszSubKey, sam, phkResult) \
  219. (SHCreateKey(HKEY_LOCAL_MACHINE, pszSubKey, sam, phkResult))
  220. #define SHCreateKeyHKCU(pszSubKey, sam, phkResult) \
  221. (SHCreateKey(HKEY_CURRENT_USER, pszSubKey, sam, phkResult))
  222. #define SHCreateKeyHKU(pszSubKey, sam, phkResult) \
  223. (SHCreateKey(HKEY_USERS, pszSubKey, sam, phkResult))
  224. #define SHOpenKey(hk, pszSubKey, sam, phkResult) \
  225. (RegOpenKeyEx((hk), (pszSubKey), 0, (sam), (phkResult)))
  226. #define SHOpenKeyHKCR(pszSubKey, sam, phkResult) \
  227. (SHOpenKey(HKEY_CLASSES_ROOT, pszSubKey, sam, phkResult))
  228. #define SHOpenKeyHKCC(pszSubKey, sam, phkResult) \
  229. (SHOpenKey(HKEY_CURRENT_CONFIG, pszSubKey, sam, phkResult))
  230. #define SHOpenKeyHKLM(pszSubKey, sam, phkResult) \
  231. (SHOpenKey(HKEY_LOCAL_MACHINE, pszSubKey, sam, phkResult))
  232. #define SHOpenKeyHKCU(pszSubKey, sam, phkResult) \
  233. (SHOpenKey(HKEY_CURRENT_USER, pszSubKey, sam, phkResult))
  234. #define SHOpenKeyHKU(pszSubKey, sam, phkResult) \
  235. (SHOpenKey(HKEY_USERS, pszSubKey, sam, phkResult))
  236. HRESULT SHCleanUpValue(HKEY hk, PCTSTR pszKey, PCTSTR pszValue = NULL);
  237. void SHCopyKey (HKEY hkFrom, HKEY hkTo);
  238. HRESULT SHCopyValue (HKEY hkFrom, HKEY hkTo, PCTSTR pszValue);
  239. HRESULT SHCopyValue (HKEY hkFrom, PCTSTR pszSubkeyFrom, HKEY hkTo, PCTSTR pszSubkeyTo, PCTSTR pszValue);
  240. HRESULT SHIsKeyEmpty (HKEY hk);
  241. HRESULT SHIsKeyEmpty (HKEY hk, PCTSTR pszSubKey);
  242. HRESULT SHKeyExists (HKEY hk, PCTSTR pszSubKey);
  243. HRESULT SHValueExists (HKEY hk, PCTSTR pszValue);
  244. HRESULT SHValueExists (HKEY hk, PCTSTR pszSubKey, PCTSTR pszValue);
  245. DWORD RegSaveRestoreDWORD(HKEY hk, PCTSTR pszValue, DWORD dwValue);
  246. #define SHCloseKey(hk) \
  247. if ((hk) != NULL) { RegCloseKey((hk)); (hk) = NULL; } else
  248. //----- Advanced File Manipulation Routines -----
  249. #define CopyFileToDir(pszFile, pszDir) (CopyFileToDirEx((pszFile), (pszDir), NULL, NULL))
  250. BOOL CopyFileToDirEx(PCTSTR pszSourceFileOrPath, PCTSTR pszTargetPath, PCTSTR pszSection = NULL, PCTSTR pszIns = NULL);
  251. BOOL AppendFile(PCTSTR pcszSrcFile, PCTSTR pcszDstFile);
  252. #define CopyHtmlImgs(pszHtmlFile, pszDestPath, pszSectionName, pszInsFile) \
  253. (CopyHtmlImgsEx((pszHtmlFile), (pszDestPath), (pszSectionName), (pszInsFile), TRUE))
  254. #define DeleteHtmlImgs(pszHtmlFile, pszDestPath, pszSectionName, pszInsFile) \
  255. (CopyHtmlImgsEx((pszHtmlFile), (pszDestPath), (pszSectionName), (pszInsFile), FALSE))
  256. void CopyHtmlImgsEx(PCTSTR pszHtmlFile, PCTSTR pszDestPath, PCTSTR pszSectionName, PCTSTR pszInsFile, BOOL fCopy);
  257. HANDLE CreateNewFile(PCTSTR pcszFileToCreate);
  258. DWORD FileSize(PCTSTR pcszFile);
  259. BOOL DeleteFileInDir(PCTSTR pszFileName, PCTSTR pszPath);
  260. #define CloseFile(h) CloseHandle(h)
  261. #define GetFilePointer(hFile) SetFilePointer((hFile), 0, NULL, FILE_CURRENT)
  262. void SetAttribAllEx(PCTSTR pcszDir, PCTSTR pcszFile, DWORD dwAtr, BOOL fRecurse);
  263. DWORD GetNumberOfFiles(PCTSTR pcszFileName, PCTSTR pcszDir);
  264. BOOL GetFreeDiskSpace (PCTSTR pcszDir, PDWORD pdwFreeSpace, PDWORD pdwFlags);
  265. DWORD FindSpaceRequired(PCTSTR pcszSrcDir, PCTSTR pcszFile, PCTSTR pcszDstDir);
  266. BOOL WriteStringToFileA (HANDLE hFile, LPCVOID pbBuf, DWORD cchSize);
  267. BOOL WriteStringToFileW (HANDLE hFile, LPCVOID pbBuf, DWORD cchSize);
  268. BOOL ReadStringFromFileA(HANDLE hFile, LPVOID pbBuf, DWORD cchSize);
  269. BOOL ReadStringFromFileW(HANDLE hFile, LPVOID pbBuf, DWORD cchSize);
  270. #ifdef _UNICODE
  271. #define WriteStringToFile WriteStringToFileW
  272. #define ReadStringFromFile ReadStringFromFileW
  273. #else
  274. #define WriteStringToFile WriteStringToFileA
  275. #define ReadStringFromFile ReadStringFromFileA
  276. #endif
  277. BOOL HasFileAttribute(DWORD dwFileAttrib, PCTSTR pcszFile, PCTSTR pcszDir = NULL);
  278. inline BOOL IsFileReadOnly(PCTSTR pcszFile, PCTSTR pcszDir = NULL)
  279. {
  280. return HasFileAttribute(FILE_ATTRIBUTE_READONLY, pcszFile, pcszDir);
  281. }
  282. BOOL IsFileCreatable(PCTSTR pcszFile);
  283. //----- Settings File Routines -----
  284. #define InsGetBool(pszSection, pszKey, fDefault, pszIns) \
  285. (GetPrivateProfileInt((pszSection), (pszKey), (fDefault), (pszIns)) ? TRUE : FALSE)
  286. #define InsGetInt(pszSection, pszKey, iDefault, pszIns) \
  287. (GetPrivateProfileInt((pszSection), (pszKey), (iDefault), (pszIns)))
  288. DWORD InsGetString(PCTSTR pszSection, PCTSTR pszKey, PTSTR pszValue, DWORD cchValue, PCTSTR pszIns,
  289. PCTSTR pszServerFile = NULL, PBOOL pfChecked = NULL);
  290. DWORD InsGetSubstString(PCTSTR pszSection, PCTSTR pszKey, PTSTR pszValue, DWORD cchValue, PCTSTR pszIns);
  291. BOOL InsGetYesNo(PCTSTR pszSection, PCTSTR pszKey, BOOL fDefault, PCTSTR pszIns);
  292. #define InsWriteBool(pszSection, pszKey, fValue, pszIns) \
  293. (WritePrivateProfileString((pszSection), (pszKey), (fValue) ? TEXT("1") : NULL, (pszIns)))
  294. #define InsWriteBoolEx(pszSection, pszKey, fDefault, pszIns) \
  295. (WritePrivateProfileString((pszSection), (pszKey), (fDefault) ? TEXT("1") : TEXT("0"), (pszIns)))
  296. void InsWriteInt(PCTSTR pszSection, PCTSTR pszKey, int iValue, PCTSTR pszIns);
  297. void InsWriteString(PCTSTR pszSection, PCTSTR pszKey, PCTSTR pszValue, PCTSTR pszIns,
  298. BOOL fChecked = TRUE, PCTSTR pszServerFile = NULL, DWORD dwFlags = 0);
  299. int InsWriteQuotedString(PCTSTR pszSection, PCTSTR pszKey, PCTSTR pszValue, PCTSTR pszIns);
  300. #define InsWriteYesNo(pszSection, pszKey, fValue, pszIns) \
  301. (WritePrivateProfileString((pszSection), (pszKey), (fValue) ? TEXT("Yes") : TEXT("No"), (pszIns)))
  302. #define InsDeleteSection(pszSection, pszIns) \
  303. (WritePrivateProfileString((pszSection), NULL, NULL, (pszIns)))
  304. #define InsDeleteKey(pszSection, pszKey, pszIns) \
  305. (WritePrivateProfileString((pszSection), (pszKey), NULL, (pszIns)))
  306. #define InsReadSections(pszSections, cchSections, pszIns) \
  307. (GetPrivateProfileString(NULL, NULL, (pszSections), (cchSections), (pszIns)))
  308. #define InsReadKeys(pszSection, pszKeys, cchKeys, pszIns) \
  309. (GetPrivateProfileString((pszSection), NULL, (pszKeys), (cchKeys), (pszIns)))
  310. #define InsFlushChanges(pszIns) \
  311. (WritePrivateProfileString(NULL, NULL, NULL, (pszIns)))
  312. BOOL InsIsSectionEmpty(PCTSTR pszSection, PCTSTR pszFile);
  313. BOOL InsIsKeyEmpty(PCTSTR pszSection, PCTSTR pszKey, PCTSTR pszFile);
  314. BOOL InsKeyExists (PCTSTR pszSection, PCTSTR pszKey, PCTSTR pszFile);
  315. #define ReadBoolAndCheckButton(pszSection, pszKey, fDefault, pszIns, hDlg, idCtrl) \
  316. (CheckDlgButton((hDlg), (idCtrl), InsGetBool((pszSection), (pszKey), (fDefault), (pszIns)) ? BST_CHECKED : BST_UNCHECKED))
  317. #define CheckButtonAndWriteBool(hDlg, idCtrl, pszSection, pszKey, pszIns) \
  318. (InsWriteBool((pszSection), (pszKey), BST_CHECKED == IsDlgButtonChecked((hDlg), (idCtrl)), (pszIns)))
  319. #define INSIO_TRISTATE 0x00000001
  320. #define INSIO_PATH 0x00000002
  321. #define INSIO_SERVERONLY 0x00000004
  322. void SetDlgItemTextFromIns(HWND hDlg, int idText, int idCheck,
  323. PCTSTR pszSection, PCTSTR pszKey, PCTSTR pszIns,
  324. PCTSTR pszServerFile, DWORD dwFlags);
  325. void WriteDlgItemTextToIns(HWND hDlg, int idText, int idCheck,
  326. PCTSTR pszSection, PCTSTR pszKey, PCTSTR pszIns,
  327. PCTSTR pcszServerFile, DWORD dwFlags);
  328. //----- Delay Load Failure Routine -----
  329. FARPROC WINAPI DelayLoadFailureHook(UINT unReason, PDelayLoadInfo pDelayInfo);
  330. //----- Miscellaneous -----
  331. typedef struct tagMAPDW2PSZ {
  332. DWORD dw;
  333. PCTSTR psz;
  334. } MAPDW2PSZ, *PMAPDW2PSZ;
  335. typedef const MAPDW2PSZ *PCMAPDW2PSZ;
  336. #define DW2PSZ_PAIR(dw) { ((DWORD)dw), TEXT(#dw) }
  337. ULONG CoTaskMemSize(PVOID pv);
  338. UINT CoStringFromGUID(REFGUID rguid, PTSTR pszBuf, UINT cchBuf);
  339. PCTSTR GetHrSz(HRESULT hr);
  340. void ConvertVersionStrToDwords(PTSTR pszVer, PDWORD pdwVer, PDWORD pdwBuild);
  341. void ConvertDwordsToVersionStr(PTSTR pszVer, DWORD dwVer, DWORD dwBuild);
  342. DWORD GetIEVersion();
  343. #define HasFlag(dwFlags, dwMask) (((DWORD)(dwFlags) & (DWORD)(dwMask)) != 0L)
  344. BOOL SetFlag(PDWORD pdwFlags, DWORD dwMask, BOOL fSet = TRUE);
  345. BOOL IsNTAdmin(VOID);
  346. HRESULT GetLcid(LCID *pLcid, PCTSTR pcszLang, PCTSTR pcszLocaleIni);
  347. UINT GetUnitsFromCb(UINT cbSrc, UINT cbUnit);
  348. #endif