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
4.7 KiB

  1. //==========================================================================;
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. // PURPOSE.
  7. //
  8. // Copyright (c) 1994-1996 Microsoft Corporation
  9. //
  10. //--------------------------------------------------------------------------;
  11. //
  12. // profile.h
  13. //
  14. // Description:
  15. //
  16. // This file contains definitions supporting the code in profile.c
  17. // which accesses the registry directly.
  18. //
  19. //==========================================================================;
  20. #ifndef _PROFILE_H_
  21. #define _PROFILE_H_
  22. #ifdef __cplusplus
  23. extern "C" // assume C declarations for C++
  24. {
  25. #endif
  26. #ifndef INLINE
  27. #define INLINE __inline
  28. #endif
  29. //
  30. // The Chicago Win16 header files are messed up somehow, so we have to
  31. // define this stuff ourselves.
  32. //
  33. #ifndef REG_DWORD
  34. #pragma message("profile.h: Manually defining REG_DWORD!!!")
  35. #define REG_DWORD ( 4 )
  36. #endif
  37. #ifndef ERROR_SUCCESS
  38. #pragma message("profile.h: Manually defining ERROR_SUCCESS!!!")
  39. #define ERROR_SUCCESS 0L
  40. #endif
  41. //--------------------------------------------------------------------------;
  42. //
  43. // Function Prototypes from profile.c
  44. //
  45. //--------------------------------------------------------------------------;
  46. HKEY FNGLOBAL IRegOpenKey
  47. (
  48. LPCTSTR pszKeyName
  49. );
  50. BOOL FNGLOBAL IRegReadString
  51. (
  52. HKEY hkey,
  53. LPCTSTR pszValue,
  54. LPTSTR pszData,
  55. DWORD cchData
  56. );
  57. DWORD FNGLOBAL IRegReadDwordDefault
  58. (
  59. HKEY hkey,
  60. LPCTSTR pszValue,
  61. DWORD dwDefault
  62. );
  63. //--------------------------------------------------------------------------;
  64. //
  65. // VOID IRegWriteString
  66. //
  67. // Description:
  68. // This routine writes a value to an opened registry key. If the key
  69. // is NULL, we return without doing anything.
  70. //
  71. // Arguments:
  72. // HKEY hkey: An open registry key.
  73. // LPCTSTR pszValue: Name of the value.
  74. // LPCTSTR pszData: The data to write.
  75. //
  76. // Return (BOOL): TRUE indicates success. FALSE otherwise.
  77. //
  78. //--------------------------------------------------------------------------;
  79. INLINE BOOL IRegWriteString
  80. (
  81. HKEY hkey,
  82. LPCTSTR pszValue,
  83. LPCTSTR pszData
  84. )
  85. {
  86. LONG lResult;
  87. lResult = RegSetValueEx( hkey, pszValue, 0L, REG_SZ, (LPBYTE)pszData,
  88. sizeof(TCHAR) * (1+lstrlen(pszData)) );
  89. return (ERROR_SUCCESS == lResult);
  90. }
  91. //--------------------------------------------------------------------------;
  92. //
  93. // VOID IRegWriteDword
  94. //
  95. // Description:
  96. // This routine writes a DWORD to the given value an open key.
  97. //
  98. // Arguments:
  99. // HKEY hkey: Registry key to read from.
  100. // LPCTSTR pszValue:
  101. // DWORD dwData:
  102. //
  103. // Return (BOOL): TRUE if successfull. FALSE otherwise
  104. //
  105. //--------------------------------------------------------------------------;
  106. INLINE BOOL IRegWriteDword
  107. (
  108. HKEY hkey,
  109. LPCTSTR pszValue,
  110. DWORD dwData
  111. )
  112. {
  113. LONG lResult;
  114. lResult = RegSetValueEx( hkey, pszValue, 0, REG_DWORD,
  115. (LPBYTE)&dwData, sizeof(DWORD) );
  116. return (ERROR_SUCCESS == lResult);
  117. }
  118. //--------------------------------------------------------------------------;
  119. //
  120. // BOOL IRegValueExists
  121. //
  122. // Description:
  123. // This routine returns TRUE if the specified value exists in the
  124. // key; otherwise FALSE is returned.
  125. //
  126. // Arguments:
  127. // HKEY hkey: An open registry key.
  128. // LPCTSTR pszValue: Name of the value.
  129. //
  130. // Return (BOOL):
  131. //
  132. //--------------------------------------------------------------------------;
  133. INLINE BOOL IRegValueExists
  134. (
  135. HKEY hkey,
  136. LPCTSTR pszValue
  137. )
  138. {
  139. return ( ERROR_SUCCESS == RegQueryValueEx( hkey, (LPTSTR)pszValue,
  140. NULL, NULL, NULL, NULL ) );
  141. }
  142. //--------------------------------------------------------------------------;
  143. //
  144. // VOID IRegCloseKey
  145. //
  146. // Description:
  147. // Closes an open key (but only if it's non-NULL).
  148. //
  149. //--------------------------------------------------------------------------;
  150. INLINE VOID IRegCloseKey
  151. (
  152. HKEY hkey
  153. )
  154. {
  155. if( NULL != hkey )
  156. {
  157. RegCloseKey( hkey );
  158. }
  159. }
  160. #ifdef __cplusplus
  161. } // end of extern "C" {
  162. #endif
  163. #endif // _PROFILE_H_