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.

194 lines
6.1 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. // All rights reserved.
  5. //
  6. // File Name:
  7. // reset.c
  8. //
  9. // Description:
  10. // This file implements ResetAnswersToDefaults(). It is called by
  11. // load.c every time the user hits NEXT on the NewOrEditPage.
  12. //
  13. // You MUST reset your global data to true defaults and you MUST
  14. // free any memory you allocated to hold setting info.
  15. //
  16. //----------------------------------------------------------------------------
  17. #include "pch.h"
  18. #include "allres.h"
  19. //
  20. // Local prototypes
  21. //
  22. static VOID ResetDistFolderNames( VOID );
  23. static VOID ResetNetSettings( int iOrigin );
  24. //----------------------------------------------------------------------------
  25. //
  26. // Function: ResetAnswersToDefaults
  27. //
  28. // Purpose: This function is called before we (possibly) load settings
  29. // from elsewhere. This is time to zero stuff out and free
  30. // relevant stuff.
  31. //
  32. // In case you need to do something different based on the reason
  33. // we're resetting, iOrigin is passed in. But note, in case of
  34. // LOAD_NEWSCRIPT_DEFAULTS, and LOAD_TRUE_DEFAULTS all work should
  35. // be finished when this routine finishes.
  36. //
  37. // Arguments:
  38. // HWND hwnd - current window
  39. // int iOrigin - how will we be setting the default answers?
  40. //
  41. // Returns: VOID
  42. //
  43. //----------------------------------------------------------------------------
  44. VOID ResetAnswersToDefaults(HWND hwnd, int iOrigin)
  45. {
  46. TCHAR *pTempString;
  47. //
  48. // Reset GenSettings and WizGlobals to true defaults.
  49. //
  50. // This is done by first zeroing out GenSettings & WizGlobals and then
  51. // assigning specific fields where 0 isn't the good default.
  52. //
  53. // Note that FixedGlobals does not get reset by design. You can declare
  54. // staticly initialized lists and such in there. For example, the timezone
  55. // page has a fixed list of valid timezones built at wizard init time.
  56. // But the current user selection is in GenSettings. The user selection
  57. // gets reset as it should and the list of valid timezones never gets
  58. // reset, as it should be.
  59. //
  60. ResetNameList(&GenSettings.ComputerNames);
  61. ResetNameList(&GenSettings.RunOnceCmds);
  62. ResetNameList(&GenSettings.PrinterNames);
  63. ZeroMemory(&WizGlobals, sizeof(WizGlobals));
  64. ZeroMemory(&GenSettings, sizeof(GenSettings));
  65. WizGlobals.bDoAdvancedPages = TRUE;
  66. WizGlobals.bCreateNewDistFolder = TRUE;
  67. GenSettings.TimeZoneIdx = TZ_IDX_UNDEFINED;
  68. GenSettings.iUnattendMode = UMODE_PROVIDE_DEFAULT;
  69. GenSettings.iTargetPath = TARGPATH_UNDEFINED;
  70. GenSettings.NumConnections = MIN_SERVER_CONNECTIONS;
  71. GenSettings.DisplayColorBits = -1;
  72. GenSettings.DisplayXResolution = -1;
  73. GenSettings.DisplayYResolution = -1;
  74. GenSettings.DisplayRefreshRate = -1;
  75. GenSettings.dwCountryCode = DONTSPECIFYSETTING;
  76. GenSettings.iDialingMethod = DONTSPECIFYSETTING;
  77. GenSettings.szAreaCode[0] = _T('\0');
  78. GenSettings.szOutsideLine[0] = _T('\0');
  79. GenSettings.IeCustomizeMethod = IE_NO_CUSTOMIZATION;
  80. GenSettings.bUseSameProxyForAllProtocols = TRUE;
  81. NetSettings.bObtainDNSServerAutomatically = TRUE;
  82. //
  83. // Give the SIF text some suggestive values.
  84. //
  85. pTempString = MyLoadString( IDS_SIF_DEFAULT_DESCRIPTION );
  86. lstrcpyn( GenSettings.szSifDescription, pTempString, AS(GenSettings.szSifDescription) );
  87. free( pTempString );
  88. pTempString = MyLoadString( IDS_SIF_DEFAULT_HELP_TEXT );
  89. lstrcpyn( GenSettings.szSifHelpText, pTempString, AS(GenSettings.szSifHelpText) );
  90. free( pTempString );
  91. //
  92. // Re-set the NetSettings struct
  93. //
  94. ResetNetSettings(iOrigin);
  95. }
  96. //----------------------------------------------------------------------------
  97. //
  98. // Function: ResetNetSettings
  99. //
  100. // Purpose: Resets all the network settings to their defaults.
  101. //
  102. //----------------------------------------------------------------------------
  103. static VOID ResetNetSettings( int iOrigin )
  104. {
  105. TCHAR *pTempString;
  106. NetSettings.iNetworkingMethod = TYPICAL_NETWORKING;
  107. NetSettings.bCreateAccount = FALSE;
  108. NetSettings.bWorkgroup = TRUE;
  109. NetSettings.WorkGroupName[0] = _T('\0');
  110. NetSettings.DomainName[0] = _T('\0');
  111. NetSettings.DomainAccount[0] = _T('\0');
  112. NetSettings.DomainPassword[0] = _T('\0');
  113. NetSettings.ConfirmPassword[0] = _T('\0');
  114. NetSettings.bObtainDNSServerAutomatically = TRUE;
  115. ResetNameList( &NetSettings.TCPIP_DNS_Domains );
  116. NetSettings.bEnableLMHosts = TRUE;
  117. lstrcpyn( NetSettings.szInternalNetworkNumber, _T("00000000"), AS(NetSettings.szInternalNetworkNumber) );
  118. // ISSUE-2002/02/28-stelo- waiting on response from DanielWe on how to add to Service
  119. // ISSUE-2002/02/28-stelo- Provider Name Unattend.txt
  120. // NetSettings.iServiceProviderName = ;
  121. lstrcpyn( NetSettings.szNetworkAddress, _T(""), AS(NetSettings.szNetworkAddress) );
  122. //
  123. // If more memory was allocated for network cards, then deallocate it
  124. // and leave just 1 netcard intact
  125. //
  126. AdjustNetworkCardMemory( 1, NetSettings.iNumberOfNetworkCards );
  127. //
  128. // Reset to only 1 network card being installed and make it the current
  129. // network card
  130. //
  131. NetSettings.iNumberOfNetworkCards = 1;
  132. NetSettings.iCurrentNetworkCard = 1;
  133. ResetNetworkAdapter( NetSettings.NetworkAdapterHead );
  134. InstallDefaultNetComponents();
  135. //
  136. // Give the domain & workgroup some suggestive values.
  137. //
  138. pTempString = MyLoadString( IDS_WORKGROUP_DEFAULT_TEXT );
  139. lstrcpyn( NetSettings.WorkGroupName, pTempString, AS(NetSettings.WorkGroupName) );
  140. free( pTempString );
  141. pTempString = MyLoadString( IDS_DOMAIN_DEFAULT_TEXT );
  142. lstrcpyn( NetSettings.DomainName, pTempString, AS(NetSettings.DomainName) );
  143. free( pTempString );
  144. }