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.

122 lines
3.8 KiB

  1. /****************************************************************************\
  2. WINPE.C / OPK Wizard (SETUPMGR.EXE)
  3. Microsoft Confidential
  4. Copyright (c) Microsoft Corporation 1998
  5. All rights reserved
  6. Source file for the OPK Wizard that contains the external and internal
  7. functions used by the Win PE tools available in setupmgr.
  8. 01/01 - Jason Cohen (JCOHEN)
  9. Added this new source file for the OPK Wizard. It includes the new
  10. function to create the winpe floppy used by winpe to download this
  11. config set.
  12. \****************************************************************************/
  13. //
  14. // Include File(s):
  15. //
  16. #include "pch.h"
  17. #include "wizard.h"
  18. #include "resource.h"
  19. //
  20. // Internal Defined Value(s):
  21. //
  22. //
  23. // Internal Function Prototype(s):
  24. //
  25. //
  26. // External Function(s):
  27. //
  28. BOOL MakeWinpeFloppy(HWND hwndParent, LPTSTR lpConfigName, LPTSTR lpWinBom)
  29. {
  30. BOOL bRet = FALSE,
  31. bDone;
  32. TCHAR szFloppyFile[MAX_PATH] = _T("a:\\");
  33. HCURSOR hcursorOld = NULL,
  34. hcursorWait = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));
  35. // First make the path to the winbom on the floppy drive.
  36. //
  37. AddPathN(szFloppyFile, FILE_WINBOM_INI,AS(szFloppyFile));
  38. do
  39. {
  40. // Ask them to insert the floppy disk.
  41. //
  42. if ( !(bDone = ( MsgBox(hwndParent, IDS_WINPEFLOPPY, IDS_APPNAME, MB_OKCANCEL | MB_APPLMODAL, lpConfigName) != IDOK )) )
  43. {
  44. // Make sure they want to overwrite any files that might
  45. // already be on there.
  46. //
  47. if ( ( !FileExists(szFloppyFile) ) ||
  48. ( MsgBox(hwndParent, IDS_WINPEOVERWRITE, IDS_APPNAME, MB_YESNO | MB_ICONQUESTION, lpConfigName) == IDYES ) )
  49. {
  50. // Change to the wait cursor.
  51. //
  52. if ( hcursorWait )
  53. hcursorOld = SetCursor(hcursorWait);
  54. if ( CopyFile(lpWinBom, szFloppyFile, FALSE) )
  55. {
  56. // It worked, so woo hoo.
  57. //
  58. bRet = bDone = TRUE;
  59. // Take out some stuff in the winbom that we don't want in there.
  60. //
  61. WritePrivateProfileSection(INI_SEC_WBOM_PREINSTALL, NULL, szFloppyFile);
  62. WritePrivateProfileSection(INI_SEC_MFULIST, NULL, szFloppyFile);
  63. // Write out stuff we only want in the WinPE WinBOM.
  64. //
  65. WritePrivateProfileString(WBOM_FACTORY_SECTION, INI_KEY_WBOM_FACTORY_TYPE, INI_VAL_WBOM_TYPE_WINPE, szFloppyFile);
  66. // Reset the cursor.
  67. //
  68. SetCursor(hcursorOld);
  69. }
  70. else
  71. {
  72. LPTSTR lpError = NULL;
  73. // Get the error message string.
  74. //
  75. if ( FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, (LPTSTR) &lpError, 0, NULL) == 0 )
  76. lpError = NULL;
  77. // Reset the cursor.
  78. //
  79. SetCursor(hcursorOld);
  80. // See if they want to try again.
  81. //
  82. bDone = ( MsgBox(hwndParent, IDS_ERR_WINPEFLOPPY, IDS_APPNAME, MB_OKCANCEL | MB_ICONSTOP | MB_APPLMODAL, lpError ? lpError : NULLSTR) != IDOK );
  83. // Free the error message string.
  84. //
  85. if ( lpError )
  86. LocalFree((HLOCAL) lpError);
  87. }
  88. }
  89. }
  90. }
  91. while ( !bDone );
  92. // Only return TRUE if we created the floppy w/o error.
  93. //
  94. return bRet;
  95. }