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.

296 lines
7.4 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. groups.c
  5. Abstract:
  6. This file implements the file copy code.
  7. Environment:
  8. WIN32 User Mode
  9. Author:
  10. Wesley Witt (wesw) 17-Feb-1996
  11. --*/
  12. #include "wizard.h"
  13. #pragma hdrstop
  14. GROUP_ITEMS RemoteAdminGroupItems[] =
  15. {
  16. { TEXT("Fax"),
  17. TEXT("Remote Administration"),
  18. TEXT("%systemroot%\\system32\\faxcfg.exe"),
  19. TEXT("%systemroot%\\system32\\faxcfg.exe"),
  20. TEXT("%systemroot%\\system32"),
  21. USE_COMMON_GROUP,
  22. 0,
  23. SW_NORMAL,
  24. 0
  25. }
  26. };
  27. #define MAX_REMOTE_ADMIN_GROUP_ITEMS (sizeof(RemoteAdminGroupItems)/sizeof(RemoteAdminGroupItems[0]))
  28. GROUP_ITEMS GroupItems[] =
  29. {
  30. { TEXT("Fax"),
  31. TEXT("Fax Queue Management"),
  32. TEXT("%systemroot%\\system32\\faxqueue.exe"),
  33. TEXT("%systemroot%\\system32\\faxqueue.exe"),
  34. TEXT("%systemroot%\\system32"),
  35. USE_COMMON_GROUP | USE_SERVER_NAME,
  36. 0,
  37. SW_NORMAL,
  38. 0
  39. },
  40. { TEXT("Fax"),
  41. TEXT("Cover Page Editor"),
  42. TEXT("%systemroot%\\system32\\faxcover.exe"),
  43. TEXT("%systemroot%\\system32\\faxcover.exe"),
  44. TEXT("%systemroot%\\system32"),
  45. USE_COMMON_GROUP,
  46. 0,
  47. SW_NORMAL,
  48. 0
  49. },
  50. { TEXT("Fax"),
  51. TEXT("Fax Send Utility"),
  52. TEXT("%systemroot%\\system32\\faxsend.exe"),
  53. TEXT("%systemroot%\\system32\\faxsend.exe"),
  54. TEXT("%systemroot%\\system32"),
  55. USE_COMMON_GROUP,
  56. 0,
  57. SW_NORMAL,
  58. 0
  59. },
  60. { TEXT("Fax"),
  61. TEXT("Fax Configuration"),
  62. TEXT("%systemroot%\\system32\\faxcfgst.exe"),
  63. TEXT("%systemroot%\\system32\\faxcfgst.exe"),
  64. TEXT("%systemroot%\\system32"),
  65. USE_COMMON_GROUP,
  66. 0,
  67. SW_NORMAL,
  68. 0
  69. },
  70. { TEXT("Fax"),
  71. TEXT("Fax Document Viewer"),
  72. TEXT("kodakimg.exe"),
  73. NULL,
  74. NULL,
  75. USE_COMMON_GROUP | USE_APP_PATH,
  76. 0,
  77. SW_NORMAL,
  78. 0
  79. },
  80. { TEXT("Fax"),
  81. TEXT("Help"),
  82. TEXT("%systemroot%\\system32\\winhlp32.exe %systemroot%\\help\\fax.hlp"),
  83. TEXT("%systemroot%\\system32\\winhlp32.exe"),
  84. TEXT("%systemroot%\\system32"),
  85. USE_COMMON_GROUP,
  86. 0,
  87. SW_NORMAL,
  88. 0
  89. }
  90. };
  91. #define MAX_GROUP_ITEMS (sizeof(GroupItems)/sizeof(GroupItems[0]))
  92. GROUP_ITEMS UserGroupItems[] =
  93. {
  94. { TEXT("Startup"),
  95. TEXT("Fax Monitor"),
  96. TEXT("%systemroot%\\system32\\faxstat.exe"),
  97. TEXT("%systemroot%\\system32\\faxstat.exe"),
  98. TEXT("%systemroot%\\system32"),
  99. USE_USER_GROUP,
  100. 0,
  101. SW_MINIMIZE,
  102. 0
  103. }
  104. };
  105. #define MAX_USER_GROUP_ITEMS (sizeof(UserGroupItems)/sizeof(UserGroupItems[0]))
  106. VOID
  107. CreateGroupItems(
  108. BOOL RemoteAdmin,
  109. LPTSTR ServerName
  110. )
  111. {
  112. DWORD i;
  113. TCHAR Buffer[MAX_PATH*2];
  114. TCHAR CommandLine[MAX_PATH*2];
  115. TCHAR IconPath[MAX_PATH*2];
  116. TCHAR WorkingDirectory[MAX_PATH*2];
  117. PGROUP_ITEMS Groups;
  118. DWORD GroupCount;
  119. HKEY hKey;
  120. LPTSTR p;
  121. DWORD Size;
  122. if (InstallMode & INSTALL_UPGRADE) {
  123. DeleteGroupItems();
  124. }
  125. hKey = OpenRegistryKey( HKEY_LOCAL_MACHINE, REGKEY_WINDOWS_CURRVER, FALSE, KEY_READ );
  126. if (hKey) {
  127. LPTSTR ProgFilesDir = GetRegistryString( hKey, REGVAL_PROGRAM_FILES_DIR, EMPTY_STRING );
  128. if (ProgFilesDir) {
  129. SetEnvironmentVariable( TEXT("%programfilesdir%"), ProgFilesDir );
  130. MemFree( ProgFilesDir );
  131. }
  132. RegCloseKey( hKey );
  133. }
  134. if (RemoteAdmin) {
  135. Groups = RemoteAdminGroupItems;
  136. GroupCount = MAX_REMOTE_ADMIN_GROUP_ITEMS;
  137. } else {
  138. Groups = GroupItems;
  139. GroupCount = MAX_GROUP_ITEMS;
  140. }
  141. for (i=0; i<GroupCount; i++) {
  142. CreateGroup( Groups[i].GroupName, Groups[i].Flags & USE_COMMON_GROUP );
  143. if (Groups[i].Flags & USE_APP_PATH) {
  144. hKey = OpenRegistryKey( HKEY_LOCAL_MACHINE, REGKEY_APP_PATHS, FALSE, KEY_READ );
  145. if (hKey) {
  146. Size = sizeof(Buffer) - sizeof(TCHAR);
  147. Buffer[0] = TEXT('\"');
  148. Size = RegQueryValue( hKey, Groups[i].CommandLine, &Buffer[1], &Size );
  149. if (Size == ERROR_SUCCESS || Size == ERROR_INVALID_DATA) {
  150. _tcscat( Buffer, TEXT("\"") );
  151. ExpandEnvironmentStrings( Buffer, CommandLine, sizeof(CommandLine)/sizeof(TCHAR) );
  152. ExpandEnvironmentStrings( &Buffer[1], IconPath, sizeof(IconPath)/sizeof(TCHAR) );
  153. IconPath[wcslen(IconPath)-1] = 0;
  154. ExpandEnvironmentStrings( &Buffer[1], WorkingDirectory, sizeof(WorkingDirectory)/sizeof(TCHAR) );
  155. p = _tcsrchr( WorkingDirectory, TEXT('\\') );
  156. if (p) {
  157. *p = 0;
  158. } else {
  159. continue;
  160. }
  161. }
  162. RegCloseKey( hKey );
  163. } else {
  164. continue;
  165. }
  166. } else {
  167. ExpandEnvironmentStrings( Groups[i].CommandLine, CommandLine, sizeof(CommandLine)/sizeof(TCHAR) );
  168. ExpandEnvironmentStrings( Groups[i].IconPath, IconPath, sizeof(IconPath)/sizeof(TCHAR) );
  169. ExpandEnvironmentStrings( Groups[i].WorkingDirectory, WorkingDirectory, sizeof(WorkingDirectory)/sizeof(TCHAR) );
  170. }
  171. if ((Groups[i].Flags & USE_SERVER_NAME) && ServerName) {
  172. _tcscat( CommandLine, TEXT(" ") );
  173. _tcscat( CommandLine, ServerName );
  174. }
  175. AddItem(
  176. Groups[i].GroupName,
  177. Groups[i].Flags & USE_COMMON_GROUP,
  178. Groups[i].Description,
  179. CommandLine,
  180. IconPath,
  181. Groups[i].IconIndex,
  182. WorkingDirectory,
  183. Groups[i].HotKey,
  184. Groups[i].ShowCmd
  185. );
  186. }
  187. if (RequestedSetupType & FAX_INSTALL_WORKSTATION) {
  188. Groups = UserGroupItems;
  189. GroupCount = MAX_USER_GROUP_ITEMS;
  190. for (i=0; i<GroupCount; i++) {
  191. ExpandEnvironmentStrings( Groups[i].CommandLine, CommandLine, sizeof(CommandLine) );
  192. ExpandEnvironmentStrings( Groups[i].IconPath, IconPath, sizeof(IconPath) );
  193. ExpandEnvironmentStrings( Groups[i].WorkingDirectory, WorkingDirectory, sizeof(WorkingDirectory) );
  194. AddItem(
  195. Groups[i].GroupName,
  196. Groups[i].Flags & USE_COMMON_GROUP,
  197. Groups[i].Description,
  198. CommandLine,
  199. IconPath,
  200. Groups[i].IconIndex,
  201. WorkingDirectory,
  202. Groups[i].HotKey,
  203. Groups[i].ShowCmd
  204. );
  205. }
  206. }
  207. }
  208. VOID
  209. DeleteGroupItems(
  210. VOID
  211. )
  212. {
  213. DWORD i;
  214. for (i=0; i<MAX_GROUP_ITEMS; i++) {
  215. DeleteItem(
  216. GroupItems[i].GroupName,
  217. GroupItems[i].Flags & USE_COMMON_GROUP,
  218. GroupItems[i].Description,
  219. FALSE
  220. );
  221. }
  222. for (i=0; i<MAX_REMOTE_ADMIN_GROUP_ITEMS; i++) {
  223. DeleteItem(
  224. RemoteAdminGroupItems[i].GroupName,
  225. RemoteAdminGroupItems[i].Flags & USE_COMMON_GROUP,
  226. RemoteAdminGroupItems[i].Description,
  227. FALSE
  228. );
  229. }
  230. for (i=0; i<MAX_USER_GROUP_ITEMS; i++) {
  231. DeleteItem(
  232. UserGroupItems[i].GroupName,
  233. UserGroupItems[i].Flags & USE_COMMON_GROUP,
  234. UserGroupItems[i].Description,
  235. FALSE
  236. );
  237. }
  238. DeleteGroup( GroupItems[0].GroupName, GroupItems[0].Flags & USE_COMMON_GROUP );
  239. }