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.

274 lines
7.5 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. // All rights reserved.
  5. //
  6. // File Name:
  7. // product.c
  8. //
  9. // Description:
  10. // This is the dlgproc for the Product page IDD_PRODUCT. It asks
  11. // if your installing unattended/remote_install etc...
  12. //
  13. //----------------------------------------------------------------------------
  14. #include "pch.h"
  15. #include "resource.h"
  16. //----------------------------------------------------------------------------
  17. //
  18. // Function: SetDistFolderNames
  19. //
  20. // Purpose: Sets the values for the distribution folder name and share name
  21. // in the global variables depending on the product selection.
  22. //
  23. // Arguments: INT nProductToInstall
  24. //
  25. // Returns: VOID
  26. //
  27. //----------------------------------------------------------------------------
  28. static VOID
  29. SetDistFolderNames( INT nProductToInstall ) {
  30. INT iNumberOfCharsCopied;
  31. TCHAR chSystemDrive;
  32. TCHAR szWindowsPath[MAX_PATH] = _T("");
  33. TCHAR szDistFolderPath[MAX_PATH] = _T("");
  34. HRESULT hrCat;
  35. iNumberOfCharsCopied = GetWindowsDirectory( szWindowsPath, MAX_PATH );
  36. if( iNumberOfCharsCopied != 0 ) {
  37. szDistFolderPath[0] = szWindowsPath[0];
  38. szDistFolderPath[1] = _T('\0');
  39. }
  40. else {
  41. //
  42. // Just guess it is the C drive if the GetWindowsDirectory function
  43. // failed
  44. //
  45. szDistFolderPath[0] = _T('C');
  46. szDistFolderPath[1] = _T('\0');
  47. }
  48. if( nProductToInstall == PRODUCT_SYSPREP )
  49. {
  50. hrCat=StringCchCat( szDistFolderPath, AS(szDistFolderPath), _T(":\\sysprep\\i386") );
  51. }
  52. else {
  53. hrCat=StringCchCat( szDistFolderPath, AS(szDistFolderPath), _T(":\\windist") );
  54. }
  55. //
  56. // Only set the dist folders if they haven't been already set, like on an
  57. // edit on an unattend.txt
  58. //
  59. if( WizGlobals.DistFolder[0] == _T('\0') ) {
  60. lstrcpyn( WizGlobals.DistFolder, szDistFolderPath, AS(WizGlobals.DistFolder) );
  61. }
  62. if( WizGlobals.DistShareName[0] == _T('\0') ) {
  63. lstrcpyn( WizGlobals.DistShareName, _T("windist"), AS(WizGlobals.DistShareName) );
  64. }
  65. }
  66. //----------------------------------------------------------------------------
  67. //
  68. // Function: OnSetActiveProduct
  69. //
  70. // Purpose: Called at SETACTIVE time.
  71. //
  72. //----------------------------------------------------------------------------
  73. VOID OnSetActiveProduct(HWND hwnd)
  74. {
  75. int nButtonId = IDC_UNATTENED_INSTALL;
  76. //
  77. // Select the proper radio button
  78. //
  79. switch( WizGlobals.iProductInstall ) {
  80. case PRODUCT_UNATTENDED_INSTALL:
  81. nButtonId = IDC_UNATTENED_INSTALL;
  82. break;
  83. case PRODUCT_SYSPREP:
  84. nButtonId = IDC_SYSPREP;
  85. break;
  86. case PRODUCT_REMOTEINSTALL:
  87. nButtonId = IDC_REMOTEINSTALL;
  88. break;
  89. default:
  90. AssertMsg( FALSE,
  91. "Invalid value for WizGlobals.iProductInstall" );
  92. break;
  93. }
  94. CheckRadioButton( hwnd,
  95. IDC_UNATTENED_INSTALL,
  96. IDC_SYSPREP,
  97. nButtonId );
  98. WIZ_BUTTONS(hwnd, PSWIZB_BACK | PSWIZB_NEXT);
  99. }
  100. //----------------------------------------------------------------------------
  101. //
  102. // Function: OnWizNextProduct
  103. //
  104. // Purpose: Store the radio button setting in the appropriate global variable
  105. // and set the dist folder path depending on the option they chose.
  106. //
  107. //----------------------------------------------------------------------------
  108. VOID
  109. OnWizNextProduct( HWND hwnd ) {
  110. INT iNewProductInstall;
  111. if( IsDlgButtonChecked(hwnd, IDC_UNATTENED_INSTALL) )
  112. {
  113. iNewProductInstall = PRODUCT_UNATTENDED_INSTALL;
  114. }
  115. else if( IsDlgButtonChecked(hwnd, IDC_SYSPREP) )
  116. {
  117. iNewProductInstall = PRODUCT_SYSPREP;
  118. }
  119. else if( IsDlgButtonChecked(hwnd, IDC_REMOTEINSTALL) )
  120. {
  121. iNewProductInstall = PRODUCT_REMOTEINSTALL;
  122. }
  123. else
  124. {
  125. iNewProductInstall = IDC_UNATTENED_INSTALL;
  126. }
  127. //
  128. // If they picked a new product and the new product is sysprep then we
  129. // have to delete all the computer names because sysprep only supports
  130. // one computer name.
  131. //
  132. if( WizGlobals.iProductInstall != iNewProductInstall )
  133. {
  134. if( iNewProductInstall == PRODUCT_SYSPREP )
  135. {
  136. ResetNameList( &GenSettings.ComputerNames );
  137. }
  138. }
  139. WizGlobals.iProductInstall = iNewProductInstall;
  140. //
  141. // Set the dist folder names based on product selection
  142. //
  143. SetDistFolderNames( WizGlobals.iProductInstall );
  144. }
  145. //----------------------------------------------------------------------------
  146. //
  147. // Function: OnRadioButtonProduct
  148. //
  149. // Purpose: Called when a radio button is pushed.
  150. //
  151. //----------------------------------------------------------------------------
  152. VOID OnRadioButtonProduct(HWND hwnd, int nButtonId)
  153. {
  154. CheckRadioButton(hwnd,
  155. IDC_UNATTENED_INSTALL,
  156. IDC_SYSPREP,
  157. nButtonId);
  158. }
  159. //----------------------------------------------------------------------------
  160. //
  161. // Function: DlgProductPage
  162. //
  163. // Purpose: This is the dialog procedure the Product page.
  164. //
  165. //----------------------------------------------------------------------------
  166. INT_PTR CALLBACK DlgProductPage(
  167. IN HWND hwnd,
  168. IN UINT uMsg,
  169. IN WPARAM wParam,
  170. IN LPARAM lParam)
  171. {
  172. BOOL bStatus = TRUE;
  173. switch (uMsg) {
  174. case WM_COMMAND:
  175. {
  176. int nButtonId;
  177. switch ( nButtonId = LOWORD(wParam) ) {
  178. case IDC_UNATTENED_INSTALL:
  179. case IDC_REMOTEINSTALL:
  180. case IDC_SYSPREP:
  181. if ( HIWORD(wParam) == BN_CLICKED )
  182. OnRadioButtonProduct(hwnd, LOWORD(wParam));
  183. break;
  184. default:
  185. bStatus = FALSE;
  186. break;
  187. }
  188. }
  189. break;
  190. case WM_NOTIFY:
  191. {
  192. LPNMHDR pnmh = (LPNMHDR)lParam;
  193. switch( pnmh->code ) {
  194. case PSN_QUERYCANCEL:
  195. WIZ_CANCEL(hwnd);
  196. break;
  197. case PSN_SETACTIVE:
  198. g_App.dwCurrentHelp = IDH_PROD_INST;
  199. // Set this flag so we get a prompt when user wants to cancel
  200. //
  201. SET_FLAG(OPK_EXIT, FALSE);
  202. SET_FLAG(OPK_CREATED, TRUE);
  203. OnSetActiveProduct(hwnd);
  204. break;
  205. case PSN_WIZNEXT:
  206. OnWizNextProduct( hwnd );
  207. bStatus = FALSE;
  208. break;
  209. case PSN_HELP:
  210. WIZ_HELP();
  211. break;
  212. default:
  213. bStatus = FALSE;
  214. break;
  215. }
  216. }
  217. break;
  218. default:
  219. bStatus = FALSE;
  220. break;
  221. }
  222. return bStatus;
  223. }