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.

247 lines
6.3 KiB

  1. #include "miginf.h"
  2. //
  3. // utils.c -- reusable utilities (unrelated to screen saver code)
  4. //
  5. VOID
  6. LogRegistryError (
  7. IN HKEY Key,
  8. IN LPCSTR ValueName
  9. );
  10. HKEY
  11. OpenRegKey (
  12. IN HKEY RootKey,
  13. IN LPCSTR Key
  14. );
  15. HKEY
  16. CreateRegKey (
  17. IN HKEY RootKey,
  18. IN LPCSTR Key
  19. );
  20. VOID
  21. CloseRegKey (
  22. IN HKEY Key
  23. );
  24. LPCSTR
  25. GetRegValueString (
  26. IN HKEY Key,
  27. IN LPCSTR ValueName
  28. );
  29. BOOL
  30. SetRegValueString (
  31. HKEY Key,
  32. LPCSTR ValueName,
  33. LPCSTR ValueStr
  34. );
  35. DWORD
  36. CountStringBytes (
  37. IN LPCSTR str
  38. );
  39. DWORD
  40. CountMultiStringBytes (
  41. IN LPCSTR str
  42. );
  43. LPSTR
  44. CopyStringAtoB (
  45. OUT LPSTR mbstrDest,
  46. IN LPCSTR mbstrStart,
  47. IN LPCSTR mbstrEnd // ptr to the first char NOT to copy
  48. );
  49. BOOL
  50. OurGetLongPathName (
  51. LPCSTR ShortPath,
  52. LPSTR Buffer
  53. );
  54. VOID
  55. ConvertSystemToSystem32 (
  56. IN OUT LPSTR Filename
  57. );
  58. //
  59. // utils.c -- helper functions specific to screen saver settings
  60. //
  61. VOID
  62. GenerateFilePaths (
  63. VOID
  64. );
  65. LPCSTR
  66. GetScrnSaveExe (
  67. VOID
  68. );
  69. BOOL
  70. CreateScreenSaverParamKey (
  71. IN LPCSTR ScreenSaverName,
  72. IN LPCSTR Value,
  73. OUT LPSTR Buffer
  74. );
  75. BOOL
  76. DecodeScreenSaverParamKey (
  77. IN LPCSTR EncodedString,
  78. OUT LPSTR ScreenSaverName,
  79. OUT LPSTR ValueName
  80. );
  81. //
  82. // savecfg.c -- functions that save things to our working directory
  83. //
  84. BOOL
  85. SaveDatFileKeyAndVal (
  86. IN LPCSTR Key,
  87. IN LPCSTR Val
  88. );
  89. BOOL
  90. CopyRegValueToDatFile (
  91. IN HKEY RegKey,
  92. IN LPCSTR ValueName
  93. );
  94. BOOL
  95. SaveControlIniSection (
  96. LPCSTR ControlIniSection,
  97. LPCSTR ScreenSaverName
  98. );
  99. //
  100. // dataconv.c -- functions that convert Win9x settings & save them on NT
  101. //
  102. BOOL
  103. CopyValuesFromDatFileToRegistry (
  104. IN HKEY RegKey,
  105. IN LPCSTR RegKeyName,
  106. IN LPCSTR ScreenSaverName,
  107. IN LPCSTR ValueArray[]
  108. );
  109. LPCSTR
  110. GetSettingsFileVal (
  111. IN LPCSTR Key
  112. );
  113. BOOL
  114. TranslateGeneralSetting (
  115. IN HKEY RegKey,
  116. IN LPCSTR Win9xSetting,
  117. IN LPCSTR WinNTSetting
  118. );
  119. BOOL
  120. SaveScrName (
  121. IN HKEY RegKey,
  122. IN LPCSTR KeyName
  123. );
  124. BOOL
  125. TranslateScreenSavers (
  126. IN HKEY RegRoot
  127. );
  128. BOOL
  129. CopyUntranslatedSettings (
  130. IN HKEY RegRoot
  131. );
  132. PCSTR
  133. ParseMessage (
  134. UINT MessageId,
  135. ...
  136. );
  137. VOID
  138. FreeMessage (
  139. PCSTR Message
  140. );
  141. //
  142. // DLL globals
  143. //
  144. extern LPCSTR g_User;
  145. extern LPSTR g_SettingsFile;
  146. extern LPSTR g_MigrateDotInf;
  147. extern LPSTR g_WorkingDirectory;
  148. extern LPSTR g_SourceDirectories;
  149. extern HANDLE g_hHeap;
  150. extern HINSTANCE g_hInst;
  151. //
  152. // Define strings
  153. //
  154. #define DEFINE_NONLOCALIZED_STRINGS \
  155. DEFMAC (S_BOOT, "boot") \
  156. DEFMAC (S_SCRNSAVE_EXE, "SCRNSAVE.EXE") \
  157. DEFMAC (S_SCRNSAVE_DOT, "Screen Saver.") \
  158. DEFMAC (S_SCRNSAVE_MASK, "Screen Saver.%s") \
  159. DEFMAC (S_EMPTY, "") \
  160. DEFMAC (S_DOUBLE_EMPTY, "\0") \
  161. DEFMAC (S_SETTINGS_MASK, "%s\\settings.dat") \
  162. DEFMAC (S_MIGINF_MASK, "%s\\migrate.inf") \
  163. DEFMAC (S_SYSTEM_INI, "system.ini") \
  164. DEFMAC (S_CONTROL_INI, "control.ini") \
  165. DEFMAC (S_BEZIER, "Bezier") \
  166. DEFMAC (S_MARQUEE, "Marquee") \
  167. DEFMAC (S_BEZIER_SETTINGS, "Screen Saver.Bezier") \
  168. DEFMAC (S_MARQUEE_SETTINGS, "Screen Saver.Marquee") \
  169. DEFMAC (S_MIGRATION_PATHS, "Migration Paths") \
  170. DEFMAC (S_CONTROL_PANEL_MASK, "Control Panel\\%s") \
  171. DEFMAC (S_LENGTH, "Length") \
  172. DEFMAC (S_WIDTH, "Width") \
  173. DEFMAC (S_LINESPEED, "LineSpeed") \
  174. DEFMAC (S_BACKGROUND_COLOR, "BackgroundColor") \
  175. DEFMAC (S_CHARSET, "CharSet") \
  176. DEFMAC (S_FONT, "Font") \
  177. DEFMAC (S_MODE, "Mode") \
  178. DEFMAC (S_SIZE, "Size") \
  179. DEFMAC (S_SPEED, "Speed") \
  180. DEFMAC (S_TEXT, "Text") \
  181. DEFMAC (S_TEXTCOLOR, "TextColor") \
  182. DEFMAC (S_ACTIVE1, "Active1") \
  183. DEFMAC (S_ACTIVE2, "Active2") \
  184. DEFMAC (S_CLEAN_SCREEN, "Clean Screen") \
  185. DEFMAC (S_ENDCOLOR1, "EndColor1") \
  186. DEFMAC (S_ENDCOLOR2, "EndColor2") \
  187. DEFMAC (S_LINES1, "Lines1") \
  188. DEFMAC (S_LINES2, "Lines2") \
  189. DEFMAC (S_STARTCOLOR1, "StartColor1") \
  190. DEFMAC (S_STARTCOLOR2, "StartColor2") \
  191. DEFMAC (S_WALKRANDOM1, "WalkRandom1") \
  192. DEFMAC (S_WALKRANDOM2, "WalkRandom2") \
  193. DEFMAC (S_DENSITY, "Denisty") \
  194. DEFMAC (S_WARPSPEED, "WarpSpeed") \
  195. DEFMAC (S_HKR, "HKR") \
  196. DEFMAC (S_DEFAULT_KEYSTR, "(unknown regkey)") \
  197. DEFMAC (S_SYSTEM_DIR, "\\system\\") \
  198. DEFMAC (S_SYSTEM32_DIR, "\\system32\\") \
  199. #define DEFINE_STRINGS DEFINE_NONLOCALIZED_STRINGS
  200. //
  201. // Declare externs for all string variables
  202. //
  203. #define DEFMAC(var,str) extern CHAR var[];
  204. DEFINE_STRINGS
  205. #undef DEFMAC