Source code of Windows XP (NT5)
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.

231 lines
4.8 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  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. --*/
  12. #include "precomp.h"
  13. extern APPINFO g_ai;
  14. /*++
  15. Routine Description:
  16. Retrieves or sets position info
  17. 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. TRUE on success, FALSE otherwise
  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. char szKeyName[] = "DlgCoordinates";
  34. //
  35. // Initialize our coordinates in case there's no data there
  36. //
  37. if (!fSave) {
  38. lppt->x = lppt->y = 0;
  39. }
  40. //
  41. // Open the registry key (or create it if the first time being used)
  42. //
  43. lRetVal = RegCreateKeyEx(HKEY_CURRENT_USER,
  44. L"Software\\Microsoft\\ShimViewer",
  45. 0,
  46. 0,
  47. REG_OPTION_NON_VOLATILE,
  48. KEY_QUERY_VALUE | KEY_SET_VALUE,
  49. 0,
  50. &hKey,
  51. &dwDisposition);
  52. if (ERROR_SUCCESS != lRetVal) {
  53. return;
  54. }
  55. //
  56. // Save or retrieve our coordinates
  57. //
  58. if (fSave) {
  59. RegSetValueEx(hKey,
  60. L"DlgCoordinates",
  61. 0,
  62. REG_BINARY,
  63. (PBYTE)lppt,
  64. sizeof(*lppt));
  65. } else {
  66. cbSize = sizeof(*lppt);
  67. RegQueryValueEx(hKey,
  68. L"DlgCoordinates",
  69. 0,
  70. 0,
  71. (PBYTE)lppt,
  72. &cbSize);
  73. }
  74. RegCloseKey(hKey);
  75. return;
  76. }
  77. /*++
  78. Routine Description:
  79. Retrieves or sets setting info.
  80. in the registry
  81. Arguments:
  82. fSave - If true, indicates we're saving data
  83. Return Value:
  84. TRUE on success, FALSE otherwise
  85. --*/
  86. void
  87. GetSaveSettings(
  88. IN BOOL fSave
  89. )
  90. {
  91. HKEY hKey;
  92. LONG lRetVal = 0;
  93. DWORD dwOnTop = 0, dwMinimize = 0, dwMonitor = 1;
  94. DWORD dwDisposition = 0, cbSize = 0;
  95. //
  96. // Open the registry key (or create it if the first time being used)
  97. //
  98. lRetVal = RegCreateKeyEx(HKEY_CURRENT_USER,
  99. L"Software\\Microsoft\\ShimViewer",
  100. 0,
  101. 0,
  102. REG_OPTION_NON_VOLATILE,
  103. KEY_ALL_ACCESS,
  104. 0,
  105. &hKey,
  106. &dwDisposition);
  107. if (ERROR_SUCCESS != lRetVal) {
  108. return;
  109. }
  110. if (fSave) {
  111. if (g_ai.fOnTop) {
  112. dwOnTop |= 1;
  113. }
  114. if (g_ai.fMinimize) {
  115. dwMinimize |= 1;
  116. }
  117. if (g_ai.fMonitor) {
  118. dwMonitor |= 1;
  119. }
  120. lRetVal = RegSetValueEx(hKey,
  121. L"AlwaysOnTop",
  122. 0,
  123. REG_DWORD,
  124. (LPBYTE)&dwOnTop,
  125. sizeof(DWORD));
  126. RegSetValueEx(hKey,
  127. L"StartMinimize",
  128. 0,
  129. REG_DWORD,
  130. (LPBYTE)&dwMinimize,
  131. sizeof(DWORD));
  132. RegSetValueEx(hKey,
  133. L"MonitorMessages",
  134. 0,
  135. REG_DWORD,
  136. (LPBYTE)&dwMonitor,
  137. sizeof(DWORD));
  138. } else {
  139. cbSize = sizeof(DWORD);
  140. RegQueryValueEx(hKey,
  141. L"AlwaysOnTop",
  142. 0,
  143. 0,
  144. (PBYTE)&dwOnTop,
  145. &cbSize);
  146. cbSize = sizeof(DWORD);
  147. RegQueryValueEx(hKey,
  148. L"StartMinimize",
  149. 0,
  150. 0,
  151. (PBYTE)&dwMinimize,
  152. &cbSize);
  153. cbSize = sizeof(DWORD);
  154. lRetVal = RegQueryValueEx(hKey,
  155. L"MonitorMessages",
  156. 0,
  157. 0,
  158. (PBYTE)&dwMonitor,
  159. &cbSize);
  160. if (dwOnTop) {
  161. g_ai.fOnTop = TRUE;
  162. }
  163. if (dwMinimize) {
  164. g_ai.fMinimize = TRUE;
  165. }
  166. if ((dwMonitor) || (ERROR_SUCCESS != lRetVal)) {
  167. g_ai.fMonitor = TRUE;
  168. }
  169. }
  170. RegCloseKey(hKey);
  171. return;
  172. }