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.

290 lines
6.9 KiB

  1. //
  2. // Chgusr.C
  3. //
  4. // Copyright (C) Citrix, 1996 All Rights Reserved.
  5. //
  6. // History:
  7. // scottn 11/19/96 - First pass
  8. //
  9. // scottn 12/5/96 - Add storage of chgusr option into registry.
  10. //
  11. // scottn 12/13/96 - Create the UNINSTALL key if necessary (upon
  12. // first install of an uninstallable)
  13. //
  14. // scottn 12/17/96 - Remove cwait (hangs on 16-bit installs). Now
  15. // just exec and go to next page. Add Finish page
  16. // which will turn option back and end tracking thread.
  17. //
  18. #include "priv.h"
  19. #ifndef DOWNLEVEL_PLATFORM
  20. #ifdef WINNT
  21. #include "appwiz.h"
  22. #include "regstr.h"
  23. #include <uastrfnc.h>
  24. #include <stdio.h>
  25. #include <process.h>
  26. #include <tsappcmp.h> // for TermsrvAppInstallMode
  27. #include "scripts.h"
  28. static LPVOID g_pAppScripts = NULL;
  29. //
  30. // Initialize the chgusr property sheet. Check the "install" radio control.
  31. //
  32. void ChgusrFinishInitPropSheet(HWND hDlg, LPARAM lParam)
  33. {
  34. LPWIZDATA lpwd = InitWizSheet(hDlg, lParam, 0);
  35. }
  36. void ChgusrFinishPrevInitPropSheet(HWND hDlg, LPARAM lParam)
  37. {
  38. LPWIZDATA lpwd = InitWizSheet(hDlg, lParam, 0);
  39. }
  40. //
  41. // Sets the appropriate wizard buttons.
  42. //
  43. void SetChgusrFinishButtons(LPWIZDATA lpwd)
  44. {
  45. // no BACK button so that they don't relaunch the app and
  46. // start a new thread, etc.
  47. int iBtns = PSWIZB_FINISH | PSWIZB_BACK;
  48. PropSheet_SetWizButtons(GetParent(lpwd->hwnd), iBtns);
  49. }
  50. void SetChgusrFinishPrevButtons(LPWIZDATA lpwd)
  51. {
  52. // no BACK button so that they don't relaunch the app and
  53. // start a new thread, etc.
  54. int iBtns = PSWIZB_NEXT;
  55. PropSheet_SetWizButtons(GetParent(lpwd->hwnd), iBtns);
  56. }
  57. //
  58. // NOTES: 1) This function assumes that lpwd->hwnd has already been set to
  59. // the dialogs hwnd.
  60. //
  61. void ChgusrFinishSetActive(LPWIZDATA lpwd)
  62. {
  63. if (lpwd->dwFlags & WDFLAG_SETUPWIZ)
  64. {
  65. TCHAR szInstruct[MAX_PATH];
  66. LoadString(g_hinst, IDS_CHGUSRFINISH, szInstruct, ARRAYSIZE(szInstruct));
  67. Static_SetText(GetDlgItem(lpwd->hwnd, IDC_SETUPMSG), szInstruct);
  68. }
  69. SetChgusrFinishButtons(lpwd);
  70. PostMessage(lpwd->hwnd, WMPRIV_POKEFOCUS, 0, 0);
  71. }
  72. void ChgusrFinishPrevSetActive(LPWIZDATA lpwd)
  73. {
  74. g_pAppScripts = ScriptManagerInitScripts();
  75. if (lpwd->dwFlags & WDFLAG_SETUPWIZ)
  76. {
  77. TCHAR szInstruct[MAX_PATH];
  78. LoadString(g_hinst, IDS_CHGUSRFINISH_PREV, szInstruct, ARRAYSIZE(szInstruct));
  79. Static_SetText(GetDlgItem(lpwd->hwnd, IDC_SETUPMSG), szInstruct);
  80. }
  81. SetChgusrFinishPrevButtons(lpwd);
  82. PostMessage(lpwd->hwnd, WMPRIV_POKEFOCUS, 0, 0);
  83. }
  84. //
  85. // Main dialog procedure for fourth page of setup wizard.
  86. //
  87. BOOL_PTR CALLBACK ChgusrFinishPrevDlgProc(HWND hDlg, UINT message , WPARAM wParam, LPARAM lParam)
  88. {
  89. NMHDR FAR *lpnm;
  90. LPPROPSHEETPAGE lpPropSheet = (LPPROPSHEETPAGE)(GetWindowLongPtr(hDlg, DWLP_USER));
  91. LPWIZDATA lpwd = NULL;
  92. if (lpPropSheet)
  93. {
  94. lpwd = (LPWIZDATA)lpPropSheet->lParam;
  95. }
  96. switch(message)
  97. {
  98. case WM_NOTIFY:
  99. lpnm = (NMHDR FAR *)lParam;
  100. switch(lpnm->code)
  101. {
  102. case PSN_SETACTIVE:
  103. if (lpwd)
  104. {
  105. lpwd->hwnd = hDlg;
  106. ChgusrFinishPrevSetActive(lpwd);
  107. }
  108. break;
  109. case PSN_WIZNEXT:
  110. break;
  111. case PSN_RESET:
  112. if (lpwd)
  113. {
  114. SetTermsrvAppInstallMode(lpwd->bPrevMode);
  115. CleanUpWizData(lpwd);
  116. }
  117. if(g_pAppScripts)
  118. {
  119. ScriptManagerRunScripts(&g_pAppScripts);
  120. }
  121. break;
  122. default:
  123. return FALSE;
  124. }
  125. break;
  126. case WM_INITDIALOG:
  127. ChgusrFinishPrevInitPropSheet(hDlg, lParam);
  128. break;
  129. case WMPRIV_POKEFOCUS:
  130. {
  131. break;
  132. }
  133. case WM_ENDSESSION:
  134. KdPrint(("ChgusrFinishPrevDlgProc - WM_ENDSESSION message received!\n"));
  135. if(g_pAppScripts)
  136. {
  137. ScriptManagerRunScripts(&g_pAppScripts);
  138. }
  139. return FALSE;
  140. case WM_DESTROY:
  141. case WM_HELP:
  142. case WM_CONTEXTMENU:
  143. break;
  144. case WM_COMMAND:
  145. switch (GET_WM_COMMAND_ID(wParam, lParam))
  146. {
  147. case IDHELP:
  148. break;
  149. case IDC_COMMAND:
  150. break;
  151. } // end of switch on WM_COMMAND
  152. break;
  153. default:
  154. return FALSE;
  155. } // end of switch on message
  156. return TRUE;
  157. } // ChgusrFinishDlgProc
  158. //
  159. // Main dialog procedure for last page of setup wizard.
  160. //
  161. BOOL_PTR CALLBACK ChgusrFinishDlgProc(HWND hDlg, UINT message , WPARAM wParam, LPARAM lParam)
  162. {
  163. NMHDR FAR *lpnm;
  164. LPPROPSHEETPAGE lpPropSheet = (LPPROPSHEETPAGE)(GetWindowLongPtr(hDlg, DWLP_USER));
  165. LPWIZDATA lpwd = NULL;
  166. if (lpPropSheet)
  167. {
  168. lpwd = (LPWIZDATA)lpPropSheet->lParam;
  169. }
  170. switch(message)
  171. {
  172. case WM_NOTIFY:
  173. lpnm = (NMHDR FAR *)lParam;
  174. switch(lpnm->code)
  175. {
  176. case PSN_SETACTIVE:
  177. if (lpwd)
  178. {
  179. lpwd->hwnd = hDlg;
  180. ChgusrFinishSetActive(lpwd);
  181. }
  182. break;
  183. case PSN_WIZFINISH:
  184. case PSN_RESET:
  185. if (lpwd)
  186. {
  187. SetTermsrvAppInstallMode(lpwd->bPrevMode);
  188. if (lpnm->code == PSN_RESET)
  189. CleanUpWizData(lpwd);
  190. }
  191. if(g_pAppScripts)
  192. {
  193. ScriptManagerRunScripts(&g_pAppScripts);
  194. }
  195. break;
  196. default:
  197. return FALSE;
  198. }
  199. break;
  200. case WM_INITDIALOG:
  201. ChgusrFinishInitPropSheet(hDlg, lParam);
  202. break;
  203. case WMPRIV_POKEFOCUS:
  204. {
  205. break;
  206. }
  207. case WM_ENDSESSION:
  208. KdPrint(("ChgusrFinishDlgProc - WM_ENDSESSION message received!\n"));
  209. if(g_pAppScripts)
  210. {
  211. ScriptManagerRunScripts(&g_pAppScripts);
  212. }
  213. return FALSE;
  214. case WM_DESTROY:
  215. case WM_HELP:
  216. case WM_CONTEXTMENU:
  217. break;
  218. case WM_COMMAND:
  219. switch (GET_WM_COMMAND_ID(wParam, lParam))
  220. {
  221. case IDHELP:
  222. break;
  223. case IDC_COMMAND:
  224. break;
  225. } // end of switch on WM_COMMAND
  226. break;
  227. default:
  228. return FALSE;
  229. } // end of switch on message
  230. return TRUE;
  231. } // ChgusrFinishDlgProc
  232. #endif // WINNT
  233. #endif // DOWNLEVEL_PLATFORM