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.

294 lines
9.8 KiB

  1. /******************************************************
  2. ICWEXT.CPP
  3. Contains definitions for global variables and
  4. functions used for including wizard pages from ICWCONN.DLL
  5. * Microsoft Confidential
  6. * Copyright (c) Microsoft Corporation 1992-1996
  7. * All rights reserved
  8. 5/14/98 donaldm created
  9. ******************************************************/
  10. #include "pre.h"
  11. #include "initguid.h" // Make DEFINE_GUID declare an instance of each GUID
  12. #include "icwacct.h"
  13. #include "icwconn.h"
  14. #include "webvwids.h" // GUIDS for the ICW WEBVIEW class
  15. #include "icwextsn.h"
  16. #include "icwcfg.h"
  17. extern BOOL g_bManualPath;
  18. extern BOOL g_bLanPath;
  19. IICW50Apprentice *gpICWCONNApprentice = NULL; // ICWCONN apprentice object
  20. IICWApprenticeEx *gpINETCFGApprentice = NULL; // ICWCONN apprentice object
  21. //+----------------------------------------------------------------------------
  22. //
  23. // Function LoadICWCONNUI
  24. //
  25. // Synopsis Loads in the ICWCONN's apprentice pages
  26. //
  27. // If the UI has previously been loaded, the function will simply
  28. // update the Next and Back pages for the apprentice.
  29. //
  30. // Uses global variable g_fICWCONNUILoaded.
  31. //
  32. //
  33. // Arguments hWizHWND -- HWND of main property sheet
  34. // uPrevDlgID -- Dialog ID apprentice should go to when user leaves
  35. // apprentice by clicking Back
  36. // uNextDlgID -- Dialog ID apprentice should go to when user leaves
  37. // apprentice by clicking Next
  38. // dwFlags -- Flags variable that should be passed to
  39. // IICWApprentice::AddWizardPages
  40. //
  41. //
  42. // Returns TRUE if all went well
  43. // FALSE otherwise
  44. //
  45. // History 5/13/98 donaldm adapted from INETCFG code
  46. //
  47. //-----------------------------------------------------------------------------
  48. BOOL LoadICWCONNUI( HWND hWizHWND, UINT uPrevDlgID, UINT uNextDlgID, DWORD dwFlags )
  49. {
  50. HRESULT hResult = E_NOTIMPL;
  51. if( g_fICWCONNUILoaded )
  52. {
  53. ASSERT( g_pCICWExtension );
  54. ASSERT( gpICWCONNApprentice );
  55. TraceMsg(TF_ICWEXTSN, TEXT("LoadICWCONNUI: UI already loaded, just reset first (%d) and last (%d) pages"),
  56. uPrevDlgID, uNextDlgID);
  57. // Set the State data for the external pages
  58. hResult = gpICWCONNApprentice->SetStateDataFromExeToDll( &gpWizardState->cmnStateData);
  59. hResult = gpICWCONNApprentice->ProcessCustomFlags(dwFlags);
  60. hResult = gpICWCONNApprentice->SetPrevNextPage( uPrevDlgID, uNextDlgID );
  61. goto LoadICWCONNUIExit;
  62. }
  63. if( !hWizHWND )
  64. {
  65. TraceMsg(TF_ICWEXTSN, TEXT("LoadICWCONNUI got a NULL hWizHWND!"));
  66. return FALSE;
  67. }
  68. // Demand load the ICWCONN apprentice DLL, so we can dynamically update it
  69. if (!gpICWCONNApprentice)
  70. {
  71. HRESULT hr;
  72. // Load the ICWCONN OLE in-proc server
  73. hr = CoCreateInstance(CLSID_ApprenticeICWCONN,NULL,CLSCTX_INPROC_SERVER,
  74. IID_IICW50Apprentice,(LPVOID *)&gpICWCONNApprentice);
  75. if ( (!SUCCEEDED(hr) || !gpICWCONNApprentice) )
  76. {
  77. g_fICWCONNUILoaded = FALSE;
  78. TraceMsg(TF_ICWEXTSN, TEXT("Unable to CoCreateInstance on IID_IICW50Apprentice! hr = %x"), hr);
  79. return FALSE;
  80. }
  81. }
  82. ASSERT(gpICWCONNApprentice);
  83. if( NULL == g_pCICWExtension )
  84. {
  85. TraceMsg(TF_ICWEXTSN, TEXT("Instantiating ICWExtension and using it to initialize ICWCONN's IICW50Apprentice"));
  86. g_pCICWExtension = new( CICWExtension );
  87. g_pCICWExtension->AddRef();
  88. g_pCICWExtension->m_hWizardHWND = hWizHWND;
  89. gpICWCONNApprentice->Initialize( g_pCICWExtension );
  90. // Initialize the DLL's state data before adding the pages.
  91. gpICWCONNApprentice->SetStateDataFromExeToDll( &gpWizardState->cmnStateData);
  92. }
  93. // Add the DLL's wizard pages
  94. hResult = gpICWCONNApprentice->AddWizardPages(dwFlags);
  95. if( !SUCCEEDED(hResult) )
  96. {
  97. goto LoadICWCONNUIExit;
  98. }
  99. hResult = gpICWCONNApprentice->SetPrevNextPage( uPrevDlgID, uNextDlgID );
  100. LoadICWCONNUIExit:
  101. if( SUCCEEDED(hResult) )
  102. {
  103. g_fICWCONNUILoaded = TRUE;
  104. return TRUE;
  105. }
  106. else
  107. {
  108. TraceMsg(TF_ICWEXTSN, TEXT("LoadICWCONNUI failed with (hex) hresult %x"), hResult);
  109. return FALSE;
  110. }
  111. }
  112. //+----------------------------------------------------------------------------
  113. //
  114. // Function LoadInetCfgUI
  115. //
  116. // Synopsis Loads in the InetCfg's apprentice pages
  117. //
  118. // If the UI has previously been loaded, the function will simply
  119. // update the Next and Back pages for the apprentice.
  120. //
  121. // Uses global variable g_fICWCONNUILoaded.
  122. //
  123. //
  124. // Arguments hWizHWND -- HWND of main property sheet
  125. // uPrevDlgID -- Dialog ID apprentice should go to when user leaves
  126. // apprentice by clicking Back
  127. // uNextDlgID -- Dialog ID apprentice should go to when user leaves
  128. // apprentice by clicking Next
  129. // dwFlags -- Flags variable that should be passed to
  130. // IICWApprentice::AddWizardPages
  131. //
  132. //
  133. // Returns TRUE if all went well
  134. // FALSE otherwise
  135. //
  136. // History 5/13/98 donaldm adapted from INETCFG code
  137. // 10/5/00 seanch No longer want to see the Mail & News stuff
  138. //
  139. //-----------------------------------------------------------------------------
  140. BOOL LoadInetCfgUI( HWND hWizHWND, UINT uPrevDlgID, UINT uNextDlgID, DWORD dwFlags )
  141. {
  142. HRESULT hResult = E_NOTIMPL;
  143. dwFlags |= (WIZ_USE_WIZARD97 | WIZ_NO_MAIL_ACCT | WIZ_NO_NEWS_ACCT);
  144. if( g_fINETCFGLoaded )
  145. {
  146. ASSERT( g_pCINETCFGExtension );
  147. ASSERT( gpINETCFGApprentice );
  148. TraceMsg(TF_ICWEXTSN, TEXT("LoadICWCONNUI: UI already loaded, just reset first (%d) and last (%d) pages"),
  149. uPrevDlgID, uNextDlgID);
  150. hResult = gpINETCFGApprentice->ProcessCustomFlags(dwFlags);
  151. //need to watch the retrun here since user may cancel out of installing files
  152. //and we don't want to hide the failure if the do.
  153. if( !SUCCEEDED(hResult) )
  154. goto LoadInetCfgUIExit;
  155. hResult = gpINETCFGApprentice->SetPrevNextPage( uPrevDlgID, uNextDlgID );
  156. goto LoadInetCfgUIExit;
  157. }
  158. if( !hWizHWND )
  159. {
  160. TraceMsg(TF_ICWEXTSN, TEXT("LoadICWCONNUI got a NULL hWizHWND!"));
  161. return FALSE;
  162. }
  163. // Demand load the ICWCONN apprentice DLL, so we can dynamically update it
  164. if (!gpINETCFGApprentice)
  165. {
  166. HRESULT hr;
  167. // Load the ICWCONN OLE in-proc server
  168. hr = CoCreateInstance(/*CLSID_ApprenticeAcctMgr*/ CLSID_ApprenticeICW,NULL,CLSCTX_INPROC_SERVER,
  169. IID_IICWApprenticeEx,(LPVOID *)&gpINETCFGApprentice);
  170. if ( (!SUCCEEDED(hr) || !gpINETCFGApprentice) )
  171. {
  172. g_fICWCONNUILoaded = FALSE;
  173. TraceMsg(TF_ICWEXTSN, TEXT("Unable to CoCreateInstance on IID_IICW50Apprentice! hr = %x"), hr);
  174. return FALSE;
  175. }
  176. }
  177. ASSERT(gpINETCFGApprentice);
  178. if( NULL == g_pCINETCFGExtension )
  179. {
  180. TraceMsg(TF_ICWEXTSN, TEXT("Instantiating ICWExtension and using it to initialize ICWCONN's IICW50Apprentice"));
  181. g_pCINETCFGExtension = new( CICWExtension );
  182. g_pCINETCFGExtension->AddRef();
  183. g_pCINETCFGExtension->m_hWizardHWND = GetParent(hWizHWND);
  184. gpINETCFGApprentice->SetDlgHwnd(hWizHWND);
  185. gpINETCFGApprentice->Initialize((struct IICWExtension *)g_pCINETCFGExtension);
  186. }
  187. hResult = gpINETCFGApprentice->AddWizardPages(dwFlags | WIZ_USE_WIZARD97);
  188. if( !SUCCEEDED(hResult) )
  189. {
  190. goto LoadInetCfgUIExit;
  191. }
  192. hResult = gpINETCFGApprentice->SetPrevNextPage( uPrevDlgID, uNextDlgID );
  193. LoadInetCfgUIExit:
  194. if( SUCCEEDED(hResult) )
  195. {
  196. g_fINETCFGLoaded = TRUE;
  197. return TRUE;
  198. }
  199. else
  200. {
  201. // Check if we are in /smartreboot mode, if so, don't add icw to runonce
  202. // to avoid infinite reboot.
  203. if (gpINETCFGApprentice && !g_bManualPath && !g_bLanPath)
  204. {
  205. HKEY hkey;
  206. // Verify that we really changed the desktop
  207. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER,
  208. ICWSETTINGSPATH,
  209. 0,
  210. KEY_ALL_ACCESS,
  211. &hkey))
  212. {
  213. DWORD dwICWErr = 0;
  214. DWORD dwTmp = sizeof(DWORD);
  215. DWORD dwType = 0;
  216. RegQueryValueEx(hkey,
  217. ICW_REGKEYERROR,
  218. NULL,
  219. &dwType,
  220. (LPBYTE)&dwICWErr,
  221. &dwTmp);
  222. RegDeleteValue(hkey, ICW_REGKEYERROR);
  223. RegCloseKey(hkey);
  224. // Bail if the desktop was not changed by us
  225. if(dwICWErr & ICW_CFGFLAG_SMARTREBOOT_MANUAL)
  226. {
  227. ShowWindow(GetParent(hWizHWND), FALSE);
  228. Reboot(GetParent(hWizHWND));
  229. gfQuitWizard = TRUE;
  230. }
  231. }
  232. }
  233. TraceMsg(TF_ICWEXTSN, TEXT("LoadInetCfgUIExit failed with (hex) hresult %x"), hResult);
  234. return FALSE;
  235. }
  236. }