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.

218 lines
4.9 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. Misc.cpp
  5. Abstract:
  6. Implements misc. functionality
  7. Notes:
  8. Unicode only.
  9. History:
  10. 05/04/2001 rparsons Created
  11. 01/11/2002 rparsons Cleaned up
  12. --*/
  13. #include "precomp.h"
  14. extern APPINFO g_ai;
  15. /*++
  16. Routine Description:
  17. Retrieves or sets position info in the registry.
  18. Arguments:
  19. fSave - If true, indicates we're saving data.
  20. *lppt - A POINT structure that contains/receives our data.
  21. Return Value:
  22. None.
  23. --*/
  24. void
  25. GetSavePositionInfo(
  26. IN BOOL fSave,
  27. IN OUT POINT* lppt
  28. )
  29. {
  30. HKEY hKey;
  31. DWORD cbSize = 0, dwDisposition = 0;
  32. LONG lRetVal = 0;
  33. //
  34. // Initialize our coordinates in case there's no data there.
  35. //
  36. if (!fSave) {
  37. lppt->x = lppt->y = 0;
  38. }
  39. //
  40. // Open the registry key (or create it if the first time being used).
  41. //
  42. lRetVal = RegCreateKeyEx(HKEY_CURRENT_USER,
  43. L"Software\\Microsoft\\ShimViewer",
  44. 0,
  45. 0,
  46. REG_OPTION_NON_VOLATILE,
  47. KEY_QUERY_VALUE | KEY_SET_VALUE,
  48. 0,
  49. &hKey,
  50. &dwDisposition);
  51. if (ERROR_SUCCESS != lRetVal) {
  52. return;
  53. }
  54. //
  55. // Save or retrieve our coordinates.
  56. //
  57. if (fSave) {
  58. RegSetValueEx(hKey,
  59. L"DlgCoordinates",
  60. 0,
  61. REG_BINARY,
  62. (const BYTE*)lppt,
  63. sizeof(*lppt));
  64. } else {
  65. cbSize = sizeof(*lppt);
  66. RegQueryValueEx(hKey,
  67. L"DlgCoordinates",
  68. 0,
  69. 0,
  70. (LPBYTE)lppt,
  71. &cbSize);
  72. }
  73. RegCloseKey(hKey);
  74. }
  75. /*++
  76. Routine Description:
  77. Retrieves or sets setting info in the registry.
  78. Arguments:
  79. fSave - If true, indicates we're saving data.
  80. Return Value:
  81. TRUE on success, FALSE otherwise.
  82. --*/
  83. void
  84. GetSaveSettings(
  85. IN BOOL fSave
  86. )
  87. {
  88. HKEY hKey;
  89. LONG lRetVal = 0;
  90. DWORD dwOnTop = 0, dwMinimize = 0, dwMonitor = 0;
  91. DWORD dwDisposition = 0, cbSize = 0;
  92. //
  93. // Open the registry key (or create it if the first time being used).
  94. //
  95. lRetVal = RegCreateKeyEx(HKEY_CURRENT_USER,
  96. L"Software\\Microsoft\\ShimViewer",
  97. 0,
  98. 0,
  99. REG_OPTION_NON_VOLATILE,
  100. KEY_ALL_ACCESS,
  101. 0,
  102. &hKey,
  103. &dwDisposition);
  104. if (ERROR_SUCCESS != lRetVal) {
  105. return;
  106. }
  107. if (fSave) {
  108. if (g_ai.fOnTop) {
  109. dwOnTop = 1;
  110. }
  111. if (g_ai.fMinimize) {
  112. dwMinimize = 1;
  113. }
  114. if (g_ai.fMonitor) {
  115. dwMonitor = 1;
  116. }
  117. lRetVal = RegSetValueEx(hKey,
  118. L"AlwaysOnTop",
  119. 0,
  120. REG_DWORD,
  121. (const BYTE*)&dwOnTop,
  122. sizeof(DWORD));
  123. RegSetValueEx(hKey,
  124. L"StartMinimize",
  125. 0,
  126. REG_DWORD,
  127. (const BYTE*)&dwMinimize,
  128. sizeof(DWORD));
  129. RegSetValueEx(hKey,
  130. L"MonitorMessages",
  131. 0,
  132. REG_DWORD,
  133. (const BYTE*)&dwMonitor,
  134. sizeof(DWORD));
  135. } else {
  136. cbSize = sizeof(DWORD);
  137. RegQueryValueEx(hKey,
  138. L"AlwaysOnTop",
  139. 0,
  140. 0,
  141. (LPBYTE)&dwOnTop,
  142. &cbSize);
  143. cbSize = sizeof(DWORD);
  144. RegQueryValueEx(hKey,
  145. L"StartMinimize",
  146. 0,
  147. 0,
  148. (LPBYTE)&dwMinimize,
  149. &cbSize);
  150. cbSize = sizeof(DWORD);
  151. lRetVal = RegQueryValueEx(hKey,
  152. L"MonitorMessages",
  153. 0,
  154. 0,
  155. (LPBYTE)&dwMonitor,
  156. &cbSize);
  157. if (dwOnTop) {
  158. g_ai.fOnTop = TRUE;
  159. }
  160. if (dwMinimize) {
  161. g_ai.fMinimize = TRUE;
  162. }
  163. if (dwMonitor || ERROR_SUCCESS != lRetVal) {
  164. g_ai.fMonitor = TRUE;
  165. }
  166. }
  167. RegCloseKey(hKey);
  168. }