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.

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