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.

2707 lines
84 KiB

  1. //
  2. // Copyright 1997 - Microsoft
  3. //
  4. // IMOS.CPP - Handles the "IntelliMirror OS" IDD_PROP_INTELLIMIRROR_OS tab
  5. //
  6. #include "pch.h"
  7. #include "addwiz.h"
  8. #include "cservice.h"
  9. #include "utils.h"
  10. #include <lm.h>
  11. #include <shlobj.h>
  12. #include <commdlg.h>
  13. DEFINE_MODULE("IMADMUI")
  14. DEFINE_THISCLASS("CAddWiz")
  15. #define THISCLASS CAddWiz
  16. #define LPTHISCLASS LPCADDWIZ
  17. #define BITMAP_WIDTH 16
  18. #define BITMAP_HEIGHT 16
  19. #define LG_BITMAP_WIDTH 32
  20. #define LG_BITMAP_HEIGHT 32
  21. #define NUM_COLUMNS 5
  22. #define SERVER_START_STRING L"\\\\%s\\" REMINST_SHARE
  23. //
  24. // CreateInstance()
  25. //
  26. HRESULT
  27. CAddWiz_CreateInstance(
  28. HWND hwndParent,
  29. LPUNKNOWN punk )
  30. {
  31. TraceFunc( "CAddWiz_CreateInstance()\n" );
  32. LPTHISCLASS lpcc = new THISCLASS( );
  33. HRESULT hr;
  34. if (lpcc == NULL) {
  35. hr = S_FALSE;
  36. } else {
  37. hr = THR( lpcc->Init( hwndParent, punk ) );
  38. delete lpcc;
  39. }
  40. HRETURN(hr);
  41. }
  42. //
  43. // Constructor
  44. //
  45. THISCLASS::THISCLASS( )
  46. {
  47. TraceClsFunc( "CAddWiz()\n" );
  48. DWORD dw;
  49. dw = LoadString( g_hInstance, IDS_NA, _szNA, ARRAYSIZE(_szNA) );
  50. Assert( dw );
  51. dw = LoadString( g_hInstance,
  52. IDS_USER_LOCATION,
  53. _szLocation,
  54. ARRAYSIZE(_szLocation) );
  55. Assert( dw );
  56. Assert( !_pszServerName );
  57. Assert( !_pszSourcePath );
  58. Assert( !_pszDestPath );
  59. Assert( !_pszSourceImage );
  60. Assert( !_pszDestImage );
  61. Assert( !_pszSourceServerName );
  62. InterlockIncrement( g_cObjects );
  63. TraceFuncExit();
  64. }
  65. //
  66. // Init()
  67. //
  68. STDMETHODIMP
  69. THISCLASS::Init(
  70. HWND hwndParent,
  71. LPUNKNOWN punk )
  72. {
  73. TraceClsFunc( "Init()\n" );
  74. if ( !punk )
  75. HRETURN(E_POINTER);
  76. HRESULT hr = S_OK;
  77. HPROPSHEETPAGE rPages[ 10 ];
  78. PROPSHEETHEADER pshead;
  79. _punk = punk;
  80. _punk->AddRef( );
  81. ZeroMemory( &pshead, sizeof(pshead) );
  82. pshead.dwSize = sizeof(pshead);
  83. pshead.dwFlags = PSH_WIZARD97 | PSH_PROPTITLE | PSH_HEADER;
  84. pshead.hInstance = g_hInstance;
  85. pshead.pszCaption = MAKEINTRESOURCE( IDS_ADD_DOT_DOT_DOT );
  86. pshead.phpage = rPages;
  87. pshead.pszbmHeader = MAKEINTRESOURCE( IDB_HEADER );
  88. pshead.hwndParent = hwndParent;
  89. AddWizardPage( &pshead, IDD_ADD_PAGE1, Page1DlgProc, IDS_PAGE1_TITLE, IDS_PAGE1_SUBTITLE, (LPARAM) this );
  90. AddWizardPage( &pshead, IDD_ADD_PAGE2, Page2DlgProc, IDS_PAGE2_TITLE, IDS_PAGE2_SUBTITLE, (LPARAM) this );
  91. AddWizardPage( &pshead, IDD_ADD_PAGE6, Page6DlgProc, IDS_PAGE6_TITLE, IDS_PAGE6_SUBTITLE, (LPARAM) this );
  92. AddWizardPage( &pshead, IDD_ADD_PAGE3, Page3DlgProc, IDS_PAGE3_TITLE, IDS_PAGE3_SUBTITLE, (LPARAM) this );
  93. AddWizardPage( &pshead, IDD_ADD_PAGE4, Page4DlgProc, IDS_PAGE4_TITLE, IDS_PAGE4_SUBTITLE, (LPARAM) this );
  94. AddWizardPage( &pshead, IDD_ADD_PAGE5, Page5DlgProc, IDS_PAGE5_TITLE, IDS_PAGE5_SUBTITLE, (LPARAM) this );
  95. AddWizardPage( &pshead, IDD_ADD_PAGE7, Page7DlgProc, IDS_PAGE7_TITLE, IDS_PAGE7_SUBTITLE, (LPARAM) this );
  96. AddWizardPage( &pshead, IDD_ADD_PAGE8, Page8DlgProc, IDS_PAGE8_TITLE, IDS_PAGE8_SUBTITLE, (LPARAM) this );
  97. AddWizardPage( &pshead, IDD_ADD_PAGE9, Page9DlgProc, IDS_PAGE9_TITLE, IDS_PAGE9_SUBTITLE, (LPARAM) this );
  98. AddWizardPage( &pshead, IDD_ADD_PAGE10, Page10DlgProc, IDS_PAGE10_TITLE, IDS_PAGE10_SUBTITLE, (LPARAM) this );
  99. PropertySheet( &pshead );
  100. HRETURN(hr);
  101. }
  102. //
  103. // Destructor
  104. //
  105. THISCLASS::~THISCLASS( )
  106. {
  107. TraceClsFunc( "~CAddWiz()\n" );
  108. Assert( !_pszPathBuffer );
  109. if ( _punk )
  110. _punk->Release( );
  111. if ( _pszServerName )
  112. TraceFree( _pszServerName );
  113. if ( _pszSourcePath )
  114. TraceFree( _pszSourcePath );
  115. if ( _pszSourceServerName )
  116. TraceFree( _pszSourceServerName );
  117. if ( _pszDestPath )
  118. TraceFree( _pszDestPath );
  119. if ( _pszSourceImage
  120. && _pszSourceImage != _szNA
  121. && _pszSourceImage != _szLocation )
  122. TraceFree( _pszSourceImage );
  123. if ( _pszDestImage
  124. && _pszDestImage != _szNA
  125. && _pszDestImage != _szLocation )
  126. TraceFree( _pszDestImage );
  127. InterlockDecrement( g_cObjects );
  128. TraceFuncExit();
  129. };
  130. // ************************************************************************
  131. //
  132. // Wizard Functions
  133. //
  134. // ************************************************************************
  135. //
  136. // _PopulateSamplesListView( )
  137. //
  138. STDMETHODIMP
  139. THISCLASS::_PopulateSamplesListView(
  140. LPWSTR pszStartPath )
  141. {
  142. TraceClsFunc( "_PopulateSamplesListView( " );
  143. TraceMsg( TF_FUNC, "pszStartPath = '%s' )\n", pszStartPath );
  144. if ( !pszStartPath )
  145. HRETURN(E_POINTER);
  146. Assert( _hDlg );
  147. Assert( _hwndList );
  148. CWaitCursor Wait;
  149. HRESULT hr;
  150. HANDLE hFind = INVALID_HANDLE_VALUE;
  151. WIN32_FIND_DATA find;
  152. ListView_DeleteAllItems( _hwndList );
  153. Assert( !_pszPathBuffer );
  154. _pszPathBuffer =
  155. (LPWSTR) TraceAllocString( LMEM_FIXED,
  156. wcslen( pszStartPath ) + MAX_PATH );
  157. if ( !_pszPathBuffer )
  158. {
  159. hr = E_OUTOFMEMORY;
  160. goto Error;
  161. }
  162. wcscpy( _pszPathBuffer, pszStartPath );
  163. hr = _EnumerateSIFs( );
  164. Error:
  165. if ( _pszPathBuffer )
  166. {
  167. TraceFree( _pszPathBuffer );
  168. _pszPathBuffer = NULL;
  169. }
  170. HRETURN(hr);
  171. }
  172. //
  173. // _PopulateTemplatesListView( )
  174. //
  175. STDMETHODIMP
  176. THISCLASS::_PopulateTemplatesListView(
  177. LPWSTR pszStartPath )
  178. {
  179. TraceClsFunc( "_PopulateTemplatesListView( " );
  180. TraceMsg( TF_FUNC, "pszStartPath = '%s' )\n", pszStartPath );
  181. if ( !pszStartPath )
  182. HRETURN(E_POINTER);
  183. Assert( _hDlg );
  184. Assert( _hwndList );
  185. CWaitCursor Wait;
  186. HRESULT hr;
  187. HANDLE hFind = INVALID_HANDLE_VALUE;
  188. WIN32_FIND_DATA find;
  189. ListView_DeleteAllItems( _hwndList );
  190. Assert( !_pszPathBuffer );
  191. _pszPathBuffer =
  192. (LPWSTR) TraceAllocString( LMEM_FIXED,
  193. wcslen( pszStartPath ) + MAX_PATH );
  194. if ( !_pszPathBuffer )
  195. {
  196. hr = E_OUTOFMEMORY;
  197. goto Error;
  198. }
  199. wcscpy( _pszPathBuffer, pszStartPath );
  200. wcscat( _pszPathBuffer, SLASH_SETUP );
  201. hr = _FindLanguageDirectory( _EnumerateTemplates );
  202. Error:
  203. if ( _pszPathBuffer )
  204. {
  205. TraceFree( _pszPathBuffer );
  206. _pszPathBuffer = NULL;
  207. }
  208. HRETURN(hr);
  209. }
  210. //
  211. // _PopulateImageListView( )
  212. //
  213. STDMETHODIMP
  214. THISCLASS::_PopulateImageListView(
  215. LPWSTR pszStartPath )
  216. {
  217. TraceClsFunc( "_PopulateImageListView( " );
  218. TraceMsg( TF_FUNC, "pszStartPath = '%s' )\n", pszStartPath );
  219. if ( !pszStartPath )
  220. HRETURN(E_POINTER);
  221. Assert( _hDlg );
  222. Assert( _hwndList );
  223. CWaitCursor Wait;
  224. HRESULT hr;
  225. HANDLE hFind = INVALID_HANDLE_VALUE;
  226. WIN32_FIND_DATA find;
  227. ListView_DeleteAllItems( _hwndList );
  228. Assert( !_pszPathBuffer );
  229. _pszPathBuffer =
  230. (LPWSTR) TraceAllocString( LMEM_FIXED,
  231. wcslen( pszStartPath ) + MAX_PATH );
  232. if ( !_pszPathBuffer )
  233. {
  234. hr = E_OUTOFMEMORY;
  235. goto Error;
  236. }
  237. wcscpy( _pszPathBuffer, pszStartPath );
  238. wcscat( _pszPathBuffer, SLASH_SETUP );
  239. hr = _FindLanguageDirectory( _EnumerateImages );
  240. Error:
  241. if ( _pszPathBuffer )
  242. {
  243. TraceFree( _pszPathBuffer );
  244. _pszPathBuffer = NULL;
  245. }
  246. HRETURN(hr);
  247. }
  248. //
  249. // _FindLanguageDirectory( )
  250. //
  251. STDMETHODIMP
  252. THISCLASS::_FindLanguageDirectory(
  253. LPNEXTOP lpNextOperation )
  254. {
  255. TraceClsFunc( "_FindLanguageDirectory( ... )\n" );
  256. HRESULT hr = S_OK;
  257. HANDLE hFind = INVALID_HANDLE_VALUE;
  258. ULONG uLength;
  259. ULONG uLength2;
  260. WIN32_FIND_DATA find;
  261. Assert( _pszPathBuffer );
  262. Assert( lpNextOperation );
  263. uLength = wcslen( _pszPathBuffer );
  264. wcscat( _pszPathBuffer, L"\\*" );
  265. uLength2 = wcslen( _pszPathBuffer ) - 1;
  266. hFind = FindFirstFile( _pszPathBuffer, &find );
  267. if ( hFind != INVALID_HANDLE_VALUE )
  268. {
  269. do
  270. {
  271. if ( find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
  272. && StrCmp( find.cFileName, L"." ) != 0
  273. && StrCmp( find.cFileName, L".." ) != 0 )
  274. {
  275. _pszPathBuffer[uLength2] = L'\0';
  276. wcscat( _pszPathBuffer, find.cFileName );
  277. hr = _FindOSDirectory( lpNextOperation );
  278. if (FAILED(hr))
  279. goto Error;
  280. }
  281. }
  282. while ( FindNextFile( hFind, &find ) );
  283. }
  284. Error:
  285. if ( hFind != INVALID_HANDLE_VALUE )
  286. FindClose( hFind );
  287. _pszPathBuffer[uLength] = L'\0';
  288. HRETURN(hr);
  289. }
  290. //
  291. // _FindOSDirectory( )
  292. //
  293. STDMETHODIMP
  294. THISCLASS::_FindOSDirectory(
  295. LPNEXTOP lpNextOperation )
  296. {
  297. TraceClsFunc( "_FindOSDirectory( ... )\n" );
  298. HRESULT hr = S_OK;
  299. HANDLE hFind = INVALID_HANDLE_VALUE;
  300. ULONG uLength;
  301. ULONG uLength2;
  302. WIN32_FIND_DATA find;
  303. Assert( _pszPathBuffer );
  304. Assert( lpNextOperation );
  305. uLength = wcslen( _pszPathBuffer );
  306. wcscat( _pszPathBuffer, SLASH_IMAGES L"\\");
  307. uLength2 = wcslen( _pszPathBuffer );
  308. wcscat( _pszPathBuffer, L"*" );
  309. hFind = FindFirstFile( _pszPathBuffer, &find );
  310. if ( hFind != INVALID_HANDLE_VALUE )
  311. {
  312. do
  313. {
  314. if ( find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
  315. && StrCmp( find.cFileName, L"." ) != 0
  316. && StrCmp( find.cFileName, L".." ) != 0 )
  317. {
  318. _pszPathBuffer[uLength2] = L'\0';
  319. wcscat( _pszPathBuffer, find.cFileName );
  320. hr = _EnumeratePlatforms( lpNextOperation );
  321. if (FAILED(hr))
  322. goto Error;
  323. }
  324. }
  325. while ( FindNextFile( hFind, &find ) );
  326. }
  327. Error:
  328. if ( hFind != INVALID_HANDLE_VALUE )
  329. FindClose( hFind );
  330. _pszPathBuffer[uLength] = L'\0';
  331. HRETURN(hr);
  332. }
  333. //
  334. // _EnumeratePlatforms( )
  335. //
  336. STDMETHODIMP
  337. THISCLASS::_EnumeratePlatforms(
  338. LPNEXTOP lpNextOperation )
  339. {
  340. TraceClsFunc( "_EnumeratePlatforms( ... )\n" );
  341. HRESULT hr = S_OK;
  342. HANDLE hFind = INVALID_HANDLE_VALUE;
  343. ULONG uLength;
  344. ULONG uLength2;
  345. WIN32_FIND_DATA find;
  346. Assert( lpNextOperation );
  347. Assert( _pszPathBuffer );
  348. uLength = wcslen( _pszPathBuffer );
  349. wcscat( _pszPathBuffer, L"\\*" );
  350. uLength2 = wcslen( _pszPathBuffer ) - 1;
  351. hFind = FindFirstFile( _pszPathBuffer, &find );
  352. if ( hFind != INVALID_HANDLE_VALUE )
  353. {
  354. do
  355. {
  356. if ( find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
  357. && StrCmp( find.cFileName, L"." ) != 0
  358. && StrCmp( find.cFileName, L".." ) != 0 )
  359. {
  360. _pszPathBuffer[uLength2] = L'\0';
  361. wcscat( _pszPathBuffer, find.cFileName );
  362. hr = lpNextOperation( this );
  363. if (FAILED(hr))
  364. goto Error;
  365. }
  366. }
  367. while ( FindNextFile( hFind, &find ) );
  368. }
  369. Error:
  370. if ( hFind != INVALID_HANDLE_VALUE )
  371. FindClose( hFind );
  372. _pszPathBuffer[uLength] = L'\0';
  373. HRETURN(hr);
  374. }
  375. //
  376. // _EnumerateTemplates( )
  377. //
  378. HRESULT
  379. THISCLASS::_EnumerateTemplates(
  380. LPTHISCLASS lpc )
  381. {
  382. TraceClsFunc( "_EnumerateTemplates( )\n" );
  383. HRESULT hr;
  384. ULONG uLength;
  385. Assert( lpc );
  386. Assert( lpc->_pszPathBuffer );
  387. uLength = wcslen( lpc->_pszPathBuffer );
  388. wcscat( lpc->_pszPathBuffer, SLASH_TEMPLATES );
  389. hr = lpc->_EnumerateSIFs( );
  390. lpc->_pszPathBuffer[uLength] = L'\0';
  391. HRETURN(hr);
  392. }
  393. //
  394. // _EnumerateImages( )
  395. //
  396. HRESULT
  397. THISCLASS::_EnumerateImages(
  398. LPTHISCLASS lpc )
  399. {
  400. TraceClsFunc( "_EnumerateImages( )\n" );
  401. HRESULT hr;
  402. Assert( lpc );
  403. hr = lpc->_CheckImageType( );
  404. if ( hr == S_OK )
  405. {
  406. hr = lpc->_AddItemToListView( );
  407. }
  408. HRETURN(hr);
  409. }
  410. //
  411. // _CheckImageType( )
  412. //
  413. // This won't add an item to the listview. It only checks to make
  414. // sure the image path points to a "Flat" image.
  415. //
  416. // Returns: S_OK - Flat image found
  417. // S_FALSE - not a flat image
  418. //
  419. HRESULT
  420. THISCLASS::_CheckImageType( )
  421. {
  422. TraceClsFunc( "_CheckImageType( )\n" );
  423. HRESULT hr = S_FALSE;
  424. HANDLE hFind = INVALID_HANDLE_VALUE;
  425. WIN32_FIND_DATA find;
  426. ULONG uLength;
  427. ULONG uLength2;
  428. Assert( _pszPathBuffer );
  429. uLength = wcslen( _pszPathBuffer );
  430. wcscat( _pszPathBuffer, SLASH_TEMPLATES L"\\");
  431. uLength2 = wcslen( _pszPathBuffer );
  432. wcscat( _pszPathBuffer, L"*.sif" );
  433. hFind = FindFirstFile( _pszPathBuffer, &find );
  434. if ( hFind != INVALID_HANDLE_VALUE )
  435. {
  436. do
  437. {
  438. if ( !(find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
  439. {
  440. WCHAR szImageType[ 40 ];
  441. _pszPathBuffer[uLength2] = L'\0';
  442. wcscat( _pszPathBuffer, find.cFileName );
  443. GetPrivateProfileString( OSCHOOSER_SIF_SECTION,
  444. OSCHOOSER_IMAGETYPE_ENTRY,
  445. L"",
  446. szImageType,
  447. ARRAYSIZE(szImageType),
  448. _pszPathBuffer );
  449. if ( StrCmpI( szImageType, OSCHOOSER_IMAGETYPE_FLAT ) == 0 )
  450. {
  451. hr = S_OK;
  452. goto Error;
  453. }
  454. }
  455. }
  456. while ( FindNextFile( hFind, &find ) );
  457. }
  458. else
  459. { // no SIFs in the templates directory, then check for ntoskrnl
  460. // in the archtecture directory. If found, this is a "Flat" image.
  461. _pszPathBuffer[uLength] = L'\0';
  462. wcscat( _pszPathBuffer, L"\\ntoskrnl.exe" );
  463. hFind = FindFirstFile( _pszPathBuffer, &find );
  464. if ( hFind != INVALID_HANDLE_VALUE )
  465. {
  466. do
  467. {
  468. if ( !(find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
  469. {
  470. Assert( StrCmpI( find.cFileName, L"ntoskrnl.exe" ) == 0 );
  471. hr = S_OK;
  472. goto Error;
  473. }
  474. }
  475. while ( FindNextFile( hFind, &find ) );
  476. }
  477. }
  478. Error:
  479. if ( hFind != INVALID_HANDLE_VALUE )
  480. FindClose( hFind );
  481. _pszPathBuffer[uLength] = L'\0';
  482. HRETURN(hr);
  483. }
  484. //
  485. // _EnumerateSIFs( )
  486. //
  487. STDMETHODIMP
  488. THISCLASS::_EnumerateSIFs( )
  489. {
  490. TraceClsFunc( "_EnumerateSIFs( ... )\n" );
  491. HRESULT hr = S_OK;
  492. HANDLE hFind = INVALID_HANDLE_VALUE;
  493. ULONG uLength;
  494. WIN32_FIND_DATA find;
  495. Assert( _pszPathBuffer );
  496. wcscat( _pszPathBuffer, L"\\*.sif" );
  497. uLength = wcslen( _pszPathBuffer ) - ARRAYSIZE(L"*.sif") + 1;
  498. hFind = FindFirstFile( _pszPathBuffer, &find );
  499. if ( hFind != INVALID_HANDLE_VALUE )
  500. {
  501. do
  502. {
  503. if ( !(find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
  504. {
  505. _pszPathBuffer[uLength] = L'\0';
  506. wcscat( _pszPathBuffer, find.cFileName );
  507. hr = _AddItemToListView( );
  508. if (FAILED(hr))
  509. goto Error;
  510. }
  511. }
  512. while ( FindNextFile( hFind, &find ) );
  513. }
  514. Error:
  515. if ( hFind != INVALID_HANDLE_VALUE )
  516. FindClose( hFind );
  517. _pszPathBuffer[uLength] = L'\0';
  518. HRETURN(hr);
  519. }
  520. //
  521. // _AddItemToListView( )
  522. //
  523. // Returns: S_OK - Item add successfully
  524. // S_FALSE - Item is not valid
  525. // E_OUTOFMEMORY - obvious
  526. //
  527. HRESULT
  528. THISCLASS::_AddItemToListView( )
  529. {
  530. TraceClsFunc( "_AddItemToListView( )\n" );
  531. Assert( _pszPathBuffer );
  532. HRESULT hr = S_OK;
  533. LPSIFINFO pSIF = NULL;
  534. LV_ITEM lvI;
  535. INT iCount = 0;
  536. LPWSTR psz;
  537. LPWSTR pszLanguage;
  538. LPWSTR pszImage;
  539. LPWSTR pszArchitecture;
  540. pSIF = (LPSIFINFO) TraceAlloc( LPTR, sizeof(SIFINFO) );
  541. if ( !pSIF )
  542. {
  543. hr = E_OUTOFMEMORY;
  544. goto Error;
  545. }
  546. pSIF->pszFilePath = (LPWSTR) TraceStrDup( _pszPathBuffer );
  547. if ( !pSIF->pszFilePath )
  548. {
  549. hr = E_OUTOFMEMORY;
  550. goto Error;
  551. }
  552. psz = &_pszPathBuffer[ wcslen( _pszPathBuffer ) - 4 ];
  553. if ( StrCmpI( psz, L".SIF" ) == 0 )
  554. {
  555. WCHAR szImageType[ 40 ];
  556. GetPrivateProfileString( OSCHOOSER_SIF_SECTION,
  557. OSCHOOSER_IMAGETYPE_ENTRY,
  558. L"",
  559. szImageType,
  560. ARRAYSIZE(szImageType),
  561. _pszPathBuffer );
  562. // only show "Flat" SIFs
  563. if ( szImageType[0] && StrCmpI( szImageType, OSCHOOSER_IMAGETYPE_FLAT ) )
  564. {
  565. hr = S_FALSE; // skipping
  566. goto Error;
  567. }
  568. pSIF->pszDescription =
  569. (LPWSTR) TraceAllocString( LMEM_FIXED,
  570. REMOTE_INSTALL_MAX_DESCRIPTION_CHAR_COUNT );
  571. if ( !pSIF->pszDescription )
  572. {
  573. hr = E_OUTOFMEMORY;
  574. goto Error;
  575. }
  576. GetPrivateProfileString( OSCHOOSER_SIF_SECTION,
  577. OSCHOOSER_DESCRIPTION_ENTRY,
  578. L"",
  579. pSIF->pszDescription,
  580. REMOTE_INSTALL_MAX_DESCRIPTION_CHAR_COUNT, // doesn't need -1
  581. _pszPathBuffer );
  582. if ( pSIF->pszDescription[0] == L'\0' )
  583. {
  584. hr = S_FALSE;
  585. goto Error; // not a valid OSChooser SIF
  586. }
  587. pSIF->pszHelpText =
  588. (LPWSTR) TraceAllocString( LMEM_FIXED,
  589. REMOTE_INSTALL_MAX_HELPTEXT_CHAR_COUNT );
  590. if ( pSIF->pszHelpText )
  591. {
  592. GetPrivateProfileString( OSCHOOSER_SIF_SECTION,
  593. OSCHOOSER_HELPTEXT_ENTRY,
  594. L"",
  595. pSIF->pszHelpText,
  596. REMOTE_INSTALL_MAX_HELPTEXT_CHAR_COUNT, // doesn't need -1
  597. _pszPathBuffer );
  598. }
  599. }
  600. // This path will be in one of these forms:
  601. // \\server\reminst\setup\english\images\nt50.wks\i386 ( Samples )
  602. // \\server\reminst\setup\english\images\nt50.wks\i386\templates ( template SIFs )
  603. // \\server\reminst\setup\english\images ( Images )
  604. // Find the language from the path
  605. psz = StrStr( _pszPathBuffer, SLASH_SETUP L"\\" );
  606. if (!psz)
  607. goto Language_NA;
  608. psz++;
  609. if ( !*psz )
  610. goto Language_NA;
  611. psz = StrChr( psz, L'\\' );
  612. if (!psz)
  613. goto Language_NA;
  614. psz++;
  615. if ( !*psz )
  616. goto Language_NA;
  617. pszLanguage = psz;
  618. psz = StrChr( psz, L'\\' );
  619. if ( psz )
  620. {
  621. *psz = L'\0'; // terminate
  622. }
  623. pSIF->pszLanguage = (LPWSTR) TraceStrDup( pszLanguage );
  624. if ( psz )
  625. {
  626. *psz = L'\\'; // restore
  627. }
  628. if ( !pSIF->pszLanguage )
  629. {
  630. hr = E_OUTOFMEMORY;
  631. goto Language_NA;
  632. }
  633. // Find the image directory name from the path
  634. psz = StrStr( _pszPathBuffer, SLASH_IMAGES L"\\" );
  635. if ( !psz )
  636. goto Image_NA;
  637. psz++;
  638. if ( !*psz )
  639. goto Image_NA;
  640. psz = StrChr( psz, L'\\' );
  641. if (!psz)
  642. goto Image_NA;
  643. psz++;
  644. if ( !*psz )
  645. goto Image_NA;
  646. pszImage = psz;
  647. psz = StrChr( psz, L'\\' );
  648. if ( psz )
  649. {
  650. *psz = L'\0'; // terminate
  651. }
  652. pSIF->pszImageFile = (LPWSTR) TraceStrDup( pszImage );
  653. if ( psz )
  654. {
  655. *psz = L'\\'; // restore
  656. }
  657. if ( !pSIF->pszImageFile )
  658. {
  659. hr = E_OUTOFMEMORY;
  660. goto Image_NA;
  661. }
  662. // Find the architecture from the path
  663. if ( !*psz )
  664. goto Architecture_NA;
  665. psz++;
  666. if ( !*psz )
  667. goto Architecture_NA;
  668. pszArchitecture = psz;
  669. psz = StrChr( psz, L'\\' );
  670. if ( psz )
  671. {
  672. *psz = L'\0'; // terminate
  673. }
  674. pSIF->pszArchitecture = (LPWSTR) TraceStrDup( pszArchitecture );
  675. if ( psz )
  676. {
  677. *psz = L'\\'; // restore
  678. }
  679. if ( !pSIF->pszArchitecture )
  680. {
  681. hr = E_OUTOFMEMORY;
  682. goto Architecture_NA;
  683. }
  684. goto Done;
  685. // Set columns that we couldn't determine to "n/a"
  686. Language_NA:
  687. pSIF->pszLanguage = _szNA;
  688. Image_NA:
  689. pSIF->pszImageFile = _szNA;
  690. Architecture_NA:
  691. pSIF->pszArchitecture = _szNA;
  692. Done:
  693. if ( !pSIF->pszDescription )
  694. {
  695. pSIF->pszDescription = (LPWSTR) TraceStrDup( pSIF->pszImageFile );
  696. if ( !pSIF->pszDescription )
  697. {
  698. hr = E_OUTOFMEMORY;
  699. goto Error;
  700. }
  701. }
  702. lvI.mask = LVIF_TEXT | LVIF_PARAM;
  703. lvI.iSubItem = 0;
  704. lvI.cchTextMax = REMOTE_INSTALL_MAX_DESCRIPTION_CHAR_COUNT;
  705. lvI.lParam = (LPARAM) pSIF;
  706. lvI.iItem = iCount;
  707. lvI.pszText = pSIF->pszDescription;
  708. iCount = ListView_InsertItem( _hwndList, &lvI );
  709. Assert( iCount != -1 );
  710. if ( iCount == -1 )
  711. goto Error;
  712. ListView_SetItemText( _hwndList, iCount, 1, pSIF->pszArchitecture );
  713. ListView_SetItemText( _hwndList, iCount, 2, pSIF->pszLanguage );
  714. // ListView_SetItemText( hwndList, iCount, 3, pSIF->pszVersion );
  715. ListView_SetItemText( _hwndList, iCount, 3, pSIF->pszImageFile );
  716. pSIF = NULL; // don't free
  717. Error:
  718. if ( pSIF )
  719. THR( _CleanupSIFInfo( pSIF ) );
  720. HRETURN(hr);
  721. }
  722. //
  723. // _CleanUpSifInfo( )
  724. //
  725. HRESULT
  726. THISCLASS::_CleanupSIFInfo(
  727. LPSIFINFO pSIF )
  728. {
  729. TraceClsFunc( "_CleanupSIFInfo( )\n" );
  730. if ( !pSIF )
  731. HRETURN(E_POINTER);
  732. if ( pSIF->pszDescription )
  733. TraceFree( pSIF->pszDescription );
  734. if ( pSIF->pszFilePath )
  735. TraceFree( pSIF->pszFilePath );
  736. //if ( pSIF->pszImageType && pSIF->pszImageType != _szNA )
  737. // TraceFree( pSIF->pszImageType );
  738. if ( pSIF->pszArchitecture && pSIF->pszArchitecture != _szNA )
  739. TraceFree( pSIF->pszArchitecture );
  740. if ( pSIF->pszLanguage && pSIF->pszLanguage != _szNA )
  741. TraceFree( pSIF->pszLanguage );
  742. if ( pSIF->pszImageFile && pSIF->pszImageFile != _szNA )
  743. TraceFree( pSIF->pszImageFile );
  744. //if ( pSIF->pszVersion && pSIF->pszVersion != _szNA )
  745. // TraceFree( pSIF->pszVersion );
  746. TraceFree( pSIF );
  747. HRETURN(S_OK);
  748. }
  749. //
  750. // _InitListView( )
  751. //
  752. HRESULT
  753. THISCLASS::_InitListView(
  754. HWND hwndList,
  755. BOOL fShowDirectoryColumn )
  756. {
  757. TraceClsFunc( "_InitListView( )\n" );
  758. CWaitCursor Wait;
  759. LV_COLUMN lvC;
  760. INT iSubItem;
  761. INT iCount;
  762. LV_ITEM lvI;
  763. WCHAR szText[ 80 ];
  764. DWORD dw;
  765. UINT uColumnWidth[ NUM_COLUMNS ] = { 215, 75, 75, 75, 75 };
  766. lvI.mask = LVIF_TEXT | LVIF_PARAM;
  767. lvI.iSubItem = 0;
  768. lvI.cchTextMax = DNS_MAX_NAME_BUFFER_LENGTH;
  769. // Create the columns
  770. lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  771. lvC.fmt = LVCFMT_LEFT;
  772. lvC.pszText = szText;
  773. // Add the columns.
  774. for ( iCount = 0; iCount < NUM_COLUMNS; iCount++ )
  775. {
  776. INT i;
  777. if ( iCount == 3 )
  778. continue; // skip "Version"
  779. if ( !fShowDirectoryColumn && iCount == 4 )
  780. continue; // skip "Directory"
  781. lvC.iSubItem = iCount;
  782. lvC.cx = uColumnWidth[iCount];
  783. dw = LoadString( g_hInstance,
  784. IDS_OS_COLUMN1 + iCount,
  785. szText,
  786. ARRAYSIZE(szText));
  787. Assert( dw );
  788. i = ListView_InsertColumn ( hwndList, iCount, &lvC );
  789. Assert( i != -1 );
  790. }
  791. ListView_DeleteAllItems( hwndList );
  792. HRETURN(S_OK);
  793. }
  794. //
  795. // Page1DlgProc( )
  796. //
  797. INT_PTR CALLBACK
  798. THISCLASS::Page1DlgProc(
  799. HWND hDlg,
  800. UINT uMsg,
  801. WPARAM wParam,
  802. LPARAM lParam )
  803. {
  804. LPTHISCLASS lpc = (LPTHISCLASS) GetWindowLongPtr( hDlg, GWLP_USERDATA );
  805. switch ( uMsg )
  806. {
  807. case WM_INITDIALOG:
  808. TraceMsg( TF_WM, "WM_INITDIALOG\n" );
  809. {
  810. HRESULT hr;
  811. WCHAR szFQDNS[ DNS_MAX_NAME_BUFFER_LENGTH ];
  812. DWORD cbSize = DNS_MAX_NAME_BUFFER_LENGTH;
  813. IIntelliMirrorSAP * pimsap = NULL;
  814. LPPROPSHEETPAGE ppsp = (LPPROPSHEETPAGE) lParam;
  815. Assert( ppsp );
  816. Assert( ppsp->lParam );
  817. SetWindowLongPtr( hDlg, GWLP_USERDATA, ppsp->lParam );
  818. lpc = (LPTHISCLASS) ppsp->lParam;
  819. Button_SetCheck( GetDlgItem( hDlg, IDC_B_ADDSIF ), BST_CHECKED );
  820. Assert( lpc->_punk );
  821. hr = THR( lpc->_punk->QueryInterface( IID_IIntelliMirrorSAP,
  822. (void**) &pimsap ) );
  823. if (hr) {
  824. goto InitDialog_Error;
  825. }
  826. Assert( !lpc->_pszServerName );
  827. hr = THR( pimsap->GetServerName( &lpc->_pszServerName ) );
  828. if (hr)
  829. goto InitDialog_Error;
  830. GetComputerNameEx( ComputerNameNetBIOS, szFQDNS, &cbSize );
  831. if ( StrCmpI( szFQDNS, lpc->_pszServerName ) == 0 )
  832. {
  833. EnableWindow( GetDlgItem( hDlg, IDC_B_NEWIMAGE ), TRUE );
  834. }
  835. InitDialog_Error:
  836. return TRUE;
  837. }
  838. break;
  839. case WM_NOTIFY:
  840. {
  841. LPNMHDR lpnmhdr = (LPNMHDR) lParam;
  842. Assert( lpc );
  843. switch( lpnmhdr->code )
  844. {
  845. case PSN_SETACTIVE:
  846. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_NEXT );
  847. break;
  848. case PSN_WIZNEXT:
  849. TraceMsg( TF_WM, "PSN_WIZNEXT\n" );
  850. if ( Button_GetCheck( GetDlgItem( hDlg, IDC_B_ADDSIF ) )
  851. == BST_CHECKED )
  852. {
  853. lpc->_fAddSif = TRUE;
  854. }
  855. else if ( Button_GetCheck( GetDlgItem( hDlg, IDC_B_NEWIMAGE ) )
  856. == BST_CHECKED )
  857. {
  858. STARTUPINFO startupInfo;
  859. PROCESS_INFORMATION pi;
  860. BOOL bRet;
  861. WCHAR szCommand[] = L"RISETUP.EXE -add";
  862. lpc->_fAddSif = FALSE;
  863. ZeroMemory( &startupInfo, sizeof( startupInfo) );
  864. startupInfo.cb = sizeof( startupInfo );
  865. bRet = CreateProcess( NULL,
  866. szCommand,
  867. NULL,
  868. NULL,
  869. TRUE,
  870. NORMAL_PRIORITY_CLASS,
  871. NULL,
  872. NULL,
  873. &startupInfo,
  874. &pi );
  875. if ( bRet )
  876. {
  877. CloseHandle( pi.hProcess );
  878. CloseHandle( pi.hThread );
  879. }
  880. else
  881. {
  882. DWORD dwErr = GetLastError( );
  883. MessageBoxFromError( hDlg,
  884. IDS_RISETUP_FAILED_TO_START,
  885. dwErr );
  886. }
  887. PropSheet_PressButton( GetParent( hDlg ), PSBTN_FINISH );
  888. }
  889. break;
  890. case PSN_QUERYCANCEL:
  891. TraceMsg( TF_WM, "PSN_QUERYCANCEL\n" );
  892. return lpc->_VerifyCancel( hDlg );
  893. }
  894. }
  895. break;
  896. }
  897. return FALSE;
  898. }
  899. //
  900. // Page2DlgProc( )
  901. //
  902. // SIF Selection dialog proc.
  903. //
  904. INT_PTR CALLBACK
  905. THISCLASS::Page2DlgProc(
  906. HWND hDlg,
  907. UINT uMsg,
  908. WPARAM wParam,
  909. LPARAM lParam )
  910. {
  911. LPTHISCLASS lpc = (LPTHISCLASS) GetWindowLongPtr( hDlg, GWLP_USERDATA );
  912. switch ( uMsg )
  913. {
  914. case WM_INITDIALOG:
  915. TraceMsg( TF_WM, "WM_INITDIALOG\n" );
  916. {
  917. LPPROPSHEETPAGE ppsp = (LPPROPSHEETPAGE) lParam;
  918. Assert( ppsp );
  919. Assert( ppsp->lParam );
  920. SetWindowLongPtr( hDlg, GWLP_USERDATA, ppsp->lParam );
  921. // lpc = (LPTHISCLASS) ppsp->lParam;
  922. return TRUE;
  923. }
  924. break;
  925. case WM_NOTIFY:
  926. {
  927. LPNMHDR lpnmhdr = (LPNMHDR) lParam;
  928. Assert( lpc );
  929. switch( lpnmhdr->code )
  930. {
  931. case PSN_SETACTIVE:
  932. TraceMsg( TF_WM, "PSN_SETACTIVE\n" );
  933. if ( !lpc->_fAddSif )
  934. {
  935. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  936. return TRUE;
  937. }
  938. else
  939. {
  940. LRESULT lResult;
  941. lpc->_fCopyFromSamples = FALSE;
  942. lpc->_fCopyFromLocation = FALSE;
  943. lpc->_fCopyFromServer = FALSE;
  944. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_B_FROMSAMPLES ) );
  945. if ( lResult == BST_CHECKED )
  946. {
  947. lpc->_fCopyFromSamples = TRUE;
  948. }
  949. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_B_SERVER ) );
  950. if ( lResult == BST_CHECKED )
  951. {
  952. lpc->_fCopyFromServer = TRUE;
  953. }
  954. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_B_LOCATION ) );
  955. if ( lResult == BST_CHECKED )
  956. {
  957. lpc->_fCopyFromLocation = TRUE;
  958. }
  959. if ( !lpc->_fCopyFromLocation
  960. && !lpc->_fCopyFromSamples && !lpc->_fCopyFromServer )
  961. {
  962. PropSheet_SetWizButtons( GetParent( hDlg ),
  963. PSWIZB_BACK );
  964. }
  965. else
  966. {
  967. PropSheet_SetWizButtons( GetParent( hDlg ),
  968. PSWIZB_BACK | PSWIZB_NEXT );
  969. }
  970. }
  971. break;
  972. case PSN_WIZNEXT:
  973. TraceMsg( TF_WM, "PSN_WIZNEXT\n" );
  974. {
  975. LRESULT lResult;
  976. lpc->_fCopyFromSamples = FALSE;
  977. lpc->_fCopyFromLocation = FALSE;
  978. lpc->_fCopyFromServer = FALSE;
  979. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_B_FROMSAMPLES ) );
  980. if ( lResult == BST_CHECKED )
  981. {
  982. lpc->_fCopyFromSamples = TRUE;
  983. }
  984. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_B_SERVER ) );
  985. if ( lResult == BST_CHECKED )
  986. {
  987. lpc->_fCopyFromServer = TRUE;
  988. }
  989. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_B_LOCATION ) );
  990. if ( lResult == BST_CHECKED )
  991. {
  992. lpc->_fCopyFromLocation = TRUE;
  993. }
  994. Assert( lpc->_fCopyFromLocation
  995. || lpc->_fCopyFromSamples
  996. || lpc->_fCopyFromServer );
  997. }
  998. break;
  999. case PSN_QUERYCANCEL:
  1000. TraceMsg( TF_WM, "PSN_QUERYCANCEL\n" );
  1001. return lpc->_VerifyCancel( hDlg );
  1002. }
  1003. }
  1004. break;
  1005. case WM_COMMAND:
  1006. TraceMsg( TF_WM, "WM_COMMAND\n" );
  1007. HWND hwnd = (HWND) lParam;
  1008. switch ( LOWORD( wParam ) )
  1009. {
  1010. case IDC_B_FROMSAMPLES:
  1011. if ( HIWORD( wParam ) == BN_CLICKED )
  1012. {
  1013. LRESULT lResult = Button_GetCheck( hwnd );
  1014. if ( lResult == BST_CHECKED )
  1015. {
  1016. PropSheet_SetWizButtons( GetParent( hDlg ),
  1017. PSWIZB_BACK | PSWIZB_NEXT );
  1018. }
  1019. return TRUE;
  1020. }
  1021. break;
  1022. case IDC_B_SERVER:
  1023. if ( HIWORD( wParam ) == BN_CLICKED )
  1024. {
  1025. LRESULT lResult = Button_GetCheck( hwnd );
  1026. if ( lResult == BST_CHECKED )
  1027. {
  1028. PropSheet_SetWizButtons( GetParent( hDlg ),
  1029. PSWIZB_BACK | PSWIZB_NEXT );
  1030. }
  1031. return TRUE;
  1032. }
  1033. break;
  1034. case IDC_B_LOCATION:
  1035. if ( HIWORD( wParam ) == BN_CLICKED )
  1036. {
  1037. LRESULT lResult = Button_GetCheck( hwnd );
  1038. if ( lResult == BST_CHECKED )
  1039. {
  1040. PropSheet_SetWizButtons( GetParent( hDlg ),
  1041. PSWIZB_BACK | PSWIZB_NEXT );
  1042. }
  1043. return TRUE;
  1044. }
  1045. break;
  1046. }
  1047. break;
  1048. }
  1049. return FALSE;
  1050. }
  1051. //
  1052. // Page3DlgProc( )
  1053. //
  1054. INT_PTR CALLBACK
  1055. THISCLASS::Page3DlgProc(
  1056. HWND hDlg,
  1057. UINT uMsg,
  1058. WPARAM wParam,
  1059. LPARAM lParam )
  1060. {
  1061. LPTHISCLASS lpc = (LPTHISCLASS) GetWindowLongPtr( hDlg, GWLP_USERDATA );
  1062. switch ( uMsg )
  1063. {
  1064. case WM_INITDIALOG:
  1065. TraceMsg( TF_WM, "WM_INITDIALOG\n" );
  1066. {
  1067. LPPROPSHEETPAGE ppsp = (LPPROPSHEETPAGE) lParam;
  1068. Assert( ppsp );
  1069. Assert( ppsp->lParam );
  1070. SetWindowLongPtr( hDlg, GWLP_USERDATA, ppsp->lParam );
  1071. // lpc = (LPTHISCLASS) ppsp->lParam;
  1072. return TRUE;
  1073. }
  1074. break;
  1075. case WM_NOTIFY:
  1076. {
  1077. LPNMHDR lpnmhdr = (LPNMHDR) lParam;
  1078. Assert( lpc );
  1079. switch( lpnmhdr->code )
  1080. {
  1081. case PSN_SETACTIVE:
  1082. TraceMsg( TF_WM, "PSN_SETACTIVE\n" );
  1083. if ( !lpc->_fAddSif || !lpc->_fCopyFromServer )
  1084. {
  1085. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  1086. return TRUE;
  1087. }
  1088. else
  1089. {
  1090. ULONG uLength =
  1091. Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_SERVER ) );
  1092. if ( !uLength )
  1093. {
  1094. PropSheet_SetWizButtons( GetParent( hDlg ),
  1095. PSWIZB_BACK );
  1096. }
  1097. else
  1098. {
  1099. PropSheet_SetWizButtons( GetParent( hDlg ),
  1100. PSWIZB_BACK | PSWIZB_NEXT );
  1101. }
  1102. }
  1103. break;
  1104. case PSN_WIZNEXT:
  1105. TraceMsg( TF_WM, "PSN_WIZNEXT\n" );
  1106. {
  1107. CWaitCursor Wait;
  1108. LPSHARE_INFO_1 psi;
  1109. HWND hwndEdit = GetDlgItem( hDlg, IDC_E_SERVER );
  1110. ULONG uLength = Edit_GetTextLength( hwndEdit );
  1111. Assert( uLength );
  1112. uLength++; // add one for the NULL
  1113. // if we had a previous buffer allocated,
  1114. // see if we can reuse it
  1115. if ( lpc->_pszSourceServerName && uLength
  1116. > wcslen(lpc->_pszSourceServerName) + 1 )
  1117. {
  1118. TraceFree( lpc->_pszSourceServerName );
  1119. lpc->_pszSourceServerName = NULL;
  1120. }
  1121. if ( !lpc->_pszSourceServerName )
  1122. {
  1123. lpc->_pszSourceServerName =
  1124. (LPWSTR) TraceAllocString( LMEM_FIXED, uLength );
  1125. if ( !lpc->_pszSourceServerName )
  1126. goto PSN_WIZNEXTABORT;
  1127. }
  1128. Edit_GetText( hwndEdit, lpc->_pszSourceServerName, uLength );
  1129. if ( NERR_Success !=
  1130. NetShareGetInfo( lpc->_pszSourceServerName,
  1131. REMINST_SHARE,
  1132. 1,
  1133. (LPBYTE *) &psi ) )
  1134. {
  1135. MessageBoxFromStrings( hDlg,
  1136. IDS_NOTARISERVER_CAPTION,
  1137. IDS_NOTARISERVER_TEXT,
  1138. MB_OK );
  1139. SetFocus( hwndEdit );
  1140. goto PSN_WIZNEXTABORT;
  1141. }
  1142. else
  1143. {
  1144. NetApiBufferFree( psi );
  1145. }
  1146. break;
  1147. PSN_WIZNEXTABORT:
  1148. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1149. return TRUE;
  1150. }
  1151. break;
  1152. case LVN_DELETEALLITEMS:
  1153. TraceMsg( TF_WM, "LVN_DELETEALLITEMS - Deleting all items.\n" );
  1154. break;
  1155. case LVN_DELETEITEM:
  1156. TraceMsg( TF_WM, "LVN_DELETEITEM - Deleting an item.\n" );
  1157. {
  1158. LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;
  1159. LPSIFINFO pSIF = (LPSIFINFO) pnmv->lParam;
  1160. THR( lpc->_CleanupSIFInfo( pSIF ) );
  1161. }
  1162. break;
  1163. case PSN_QUERYCANCEL:
  1164. TraceMsg( TF_WM, "PSN_QUERYCANCEL\n" );
  1165. return lpc->_VerifyCancel( hDlg );
  1166. }
  1167. }
  1168. break;
  1169. case WM_COMMAND:
  1170. TraceMsg( TF_WM, "WM_COMMAND\n" );
  1171. HWND hwnd = (HWND) lParam;
  1172. switch ( LOWORD( wParam ) )
  1173. {
  1174. case IDC_E_SERVER:
  1175. if ( HIWORD( wParam ) == EN_CHANGE )
  1176. {
  1177. LONG uLength = Edit_GetTextLength( hwnd );
  1178. if ( !uLength )
  1179. {
  1180. PropSheet_SetWizButtons( GetParent( hDlg ),
  1181. PSWIZB_BACK );
  1182. }
  1183. else
  1184. {
  1185. PropSheet_SetWizButtons( GetParent( hDlg ),
  1186. PSWIZB_BACK | PSWIZB_NEXT );
  1187. }
  1188. return TRUE;
  1189. }
  1190. break;
  1191. case IDC_B_BROWSE:
  1192. if ( HIWORD( wParam ) == BN_CLICKED )
  1193. {
  1194. _OnSearch( hDlg );
  1195. }
  1196. break;
  1197. }
  1198. break;
  1199. }
  1200. return FALSE;
  1201. }
  1202. HRESULT
  1203. THISCLASS::_OnSearch(
  1204. HWND hDlg )
  1205. {
  1206. TraceClsFunc( "_OnSearch( )\n" );
  1207. HRESULT hr = E_FAIL;
  1208. DSQUERYINITPARAMS dqip;
  1209. OPENQUERYWINDOW oqw;
  1210. LPDSOBJECTNAMES pDsObjects;
  1211. VARIANT var;
  1212. ICommonQuery * pCommonQuery = NULL;
  1213. IDataObject *pdo;
  1214. VariantInit( &var );
  1215. hr = THR( CoCreateInstance( CLSID_CommonQuery, NULL, CLSCTX_INPROC_SERVER, IID_ICommonQuery, (PVOID *)&pCommonQuery) );
  1216. if (hr)
  1217. goto Error;
  1218. ZeroMemory( &dqip, sizeof(dqip) );
  1219. dqip.cbStruct = sizeof(dqip);
  1220. dqip.dwFlags = DSQPF_NOSAVE | DSQPF_SHOWHIDDENOBJECTS | DSQPF_ENABLEADMINFEATURES;
  1221. dqip.dwFlags |= DSQPF_ENABLEADVANCEDFEATURES;
  1222. ZeroMemory( &oqw, sizeof(oqw) );
  1223. oqw.cbStruct = sizeof(oqw);
  1224. oqw.dwFlags = OQWF_SHOWOPTIONAL | OQWF_ISSUEONOPEN
  1225. | OQWF_REMOVESCOPES | OQWF_REMOVEFORMS
  1226. | OQWF_DEFAULTFORM | OQWF_OKCANCEL | OQWF_SINGLESELECT;
  1227. oqw.clsidHandler = CLSID_DsQuery;
  1228. oqw.pHandlerParameters = &dqip;
  1229. oqw.clsidDefaultForm = CLSID_RISrvQueryForm;
  1230. hr = pCommonQuery->OpenQueryWindow( hDlg, &oqw, &pdo);
  1231. if ( SUCCEEDED(hr) && pdo) {
  1232. FORMATETC fmte = {
  1233. (CLIPFORMAT)g_cfDsObjectNames,
  1234. NULL,
  1235. DVASPECT_CONTENT,
  1236. -1,
  1237. TYMED_HGLOBAL};
  1238. STGMEDIUM medium = { TYMED_HGLOBAL, NULL, NULL };
  1239. //
  1240. // Retrieve the result from the IDataObject,
  1241. // in this case CF_DSOBJECTNAMES (dsclient.h)
  1242. // is needed because it describes
  1243. // the objects which were selected by the user.
  1244. //
  1245. hr = pdo->GetData(&fmte, &medium);
  1246. if ( SUCCEEDED(hr) ) {
  1247. DSOBJECTNAMES *pdon = (DSOBJECTNAMES*)GlobalLock(medium.hGlobal);
  1248. PWSTR p,FQDN;
  1249. //
  1250. // we want the name of the computer object that was selected.
  1251. // crack the DSOBJECTNAMES structure to get this data,
  1252. // convert it into a version that the user can view, and set the
  1253. // dialog text to this data.
  1254. //
  1255. if ( pdon ) {
  1256. Assert( pdon->cItems == 1);
  1257. p = (PWSTR)((ULONG_PTR)pdon + (ULONG_PTR)pdon->aObjects[0].offsetName);
  1258. if (p && (p = wcsstr(p, L"LDAP://"))) {
  1259. p += 6;
  1260. if ((p = wcsstr(p, L"/CN="))) {
  1261. p += 1;
  1262. hr = DNtoFQDN( p, &FQDN);
  1263. if (SUCCEEDED(hr)) {
  1264. SetDlgItemText( hDlg, IDC_E_SERVER, FQDN );
  1265. TraceFree( FQDN );
  1266. }
  1267. }
  1268. }
  1269. GlobalUnlock(medium.hGlobal);
  1270. }
  1271. }
  1272. ReleaseStgMedium(&medium);
  1273. pdo->Release();
  1274. }
  1275. Error:
  1276. if ( pCommonQuery )
  1277. pCommonQuery->Release();
  1278. if (FAILED(hr)) {
  1279. MessageBoxFromStrings(
  1280. hDlg,
  1281. IDS_PROBLEM_SEARCHING_TITLE,
  1282. IDS_PROBLEM_SEARCHING_TEXT,
  1283. MB_ICONEXCLAMATION );
  1284. }
  1285. HRETURN(hr);
  1286. }
  1287. //
  1288. // Page4DlgProc( )
  1289. //
  1290. INT_PTR CALLBACK
  1291. THISCLASS::Page4DlgProc(
  1292. HWND hDlg,
  1293. UINT uMsg,
  1294. WPARAM wParam,
  1295. LPARAM lParam )
  1296. {
  1297. LPTHISCLASS lpc = (LPTHISCLASS) GetWindowLongPtr( hDlg, GWLP_USERDATA );
  1298. switch ( uMsg )
  1299. {
  1300. case WM_INITDIALOG:
  1301. TraceMsg( TF_WM, "WM_INITDIALOG\n" );
  1302. {
  1303. LPPROPSHEETPAGE ppsp = (LPPROPSHEETPAGE) lParam;
  1304. Assert( ppsp );
  1305. Assert( ppsp->lParam );
  1306. SetWindowLongPtr( hDlg, GWLP_USERDATA, ppsp->lParam );
  1307. lpc = (LPTHISCLASS) ppsp->lParam;
  1308. THR( lpc->_InitListView( GetDlgItem( hDlg, IDC_L_SIFS ), TRUE ) );
  1309. return TRUE;
  1310. }
  1311. break;
  1312. case WM_NOTIFY:
  1313. {
  1314. LPNMHDR lpnmhdr = (LPNMHDR) lParam;
  1315. Assert( lpc );
  1316. switch( lpnmhdr->code )
  1317. {
  1318. case PSN_SETACTIVE:
  1319. TraceMsg( TF_WM, "PSN_SETACTIVE\n" );
  1320. if ( !lpc->_fAddSif || !lpc->_fCopyFromServer )
  1321. {
  1322. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  1323. return TRUE;
  1324. }
  1325. Assert( lpc->_pszSourceServerName );
  1326. if ( lpc->_pszSourceServerName )
  1327. {
  1328. LPWSTR pszStartPath =
  1329. (LPWSTR) TraceAllocString( LMEM_FIXED,
  1330. wcslen( lpc->_pszSourceServerName )
  1331. + ARRAYSIZE(SERVER_START_STRING) );
  1332. if ( pszStartPath )
  1333. {
  1334. wsprintf( pszStartPath,
  1335. SERVER_START_STRING,
  1336. lpc->_pszSourceServerName );
  1337. lpc->_hDlg = hDlg;
  1338. lpc->_hwndList = GetDlgItem( hDlg, IDC_L_SIFS );
  1339. lpc->_PopulateTemplatesListView( pszStartPath );
  1340. TraceFree( pszStartPath );
  1341. }
  1342. }
  1343. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK );
  1344. break;
  1345. case PSN_WIZNEXT:
  1346. TraceMsg( TF_WM, "PSN_WIZNEXT\n" );
  1347. {
  1348. LVITEM lvi;
  1349. HWND hwndList = GetDlgItem( hDlg, IDC_L_SIFS );
  1350. lvi.iItem = ListView_GetNextItem( hwndList, -1, LVNI_SELECTED );
  1351. Assert( lvi.iItem != -1 );
  1352. lvi.iSubItem = 0;
  1353. lvi.mask = LVIF_PARAM;
  1354. ListView_GetItem( hwndList, &lvi );
  1355. Assert(lvi.lParam);
  1356. LPSIFINFO pSIF = (LPSIFINFO) lvi.lParam;
  1357. if ( lpc->_pszSourcePath )
  1358. TraceFree( lpc->_pszSourcePath );
  1359. // no need to NULL since it is set below
  1360. if ( lpc->_pszSourceImage
  1361. && lpc->_pszSourceImage != lpc->_szNA
  1362. && lpc->_pszSourceImage != lpc->_szLocation )
  1363. TraceFree( lpc->_pszSourceImage );
  1364. // no need to NULL since it is set below
  1365. lpc->_pszSourcePath = pSIF->pszFilePath;
  1366. lpc->_pszSourceImage = pSIF->pszImageFile;
  1367. pSIF->pszFilePath = NULL; // don't free this, we're using it
  1368. pSIF->pszImageFile = NULL; // don't free this, we're using it
  1369. ListView_DeleteAllItems( hwndList );
  1370. }
  1371. break;
  1372. case PSN_QUERYCANCEL:
  1373. TraceMsg( TF_WM, "PSN_QUERYCANCEL\n" );
  1374. return lpc->_VerifyCancel( hDlg );
  1375. case LVN_DELETEALLITEMS:
  1376. TraceMsg( TF_WM, "LVN_DELETEALLITEMS - Deleting all items.\n" );
  1377. break;
  1378. case LVN_DELETEITEM:
  1379. TraceMsg( TF_WM, "LVN_DELETEITEM - Deleting an item.\n" );
  1380. {
  1381. LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;
  1382. LPSIFINFO pSIF = (LPSIFINFO) pnmv->lParam;
  1383. THR( lpc->_CleanupSIFInfo( pSIF ) );
  1384. }
  1385. break;
  1386. case LVN_ITEMCHANGED:
  1387. {
  1388. HWND hwndList = GetDlgItem( hDlg, IDC_L_SIFS );
  1389. UINT iItems = ListView_GetNextItem( hwndList, -1, LVNI_SELECTED );
  1390. if ( iItems != -1 )
  1391. {
  1392. PropSheet_SetWizButtons( GetParent( hDlg ),
  1393. PSWIZB_BACK | PSWIZB_NEXT );
  1394. }
  1395. else
  1396. {
  1397. PropSheet_SetWizButtons( GetParent( hDlg ),
  1398. PSWIZB_BACK );
  1399. }
  1400. }
  1401. break;
  1402. }
  1403. }
  1404. break;
  1405. }
  1406. return FALSE;
  1407. }
  1408. //
  1409. // Page5DlgProc( )
  1410. //
  1411. INT_PTR CALLBACK
  1412. THISCLASS::Page5DlgProc(
  1413. HWND hDlg,
  1414. UINT uMsg,
  1415. WPARAM wParam,
  1416. LPARAM lParam )
  1417. {
  1418. LPTHISCLASS lpc = (LPTHISCLASS) GetWindowLongPtr( hDlg, GWLP_USERDATA );
  1419. switch ( uMsg )
  1420. {
  1421. case WM_INITDIALOG:
  1422. TraceMsg( TF_WM, "WM_INITDIALOG\n" );
  1423. {
  1424. LPPROPSHEETPAGE ppsp = (LPPROPSHEETPAGE) lParam;
  1425. Assert( ppsp );
  1426. Assert( ppsp->lParam );
  1427. SetWindowLongPtr( hDlg, GWLP_USERDATA, ppsp->lParam );
  1428. Edit_LimitText( GetDlgItem( hDlg, IDC_E_FILEPATH ), MAX_PATH );
  1429. SHAutoComplete(GetDlgItem( hDlg, IDC_E_FILEPATH ), SHACF_AUTOSUGGEST_FORCE_ON | SHACF_FILESYSTEM);
  1430. // lpc = (LPTHISCLASS) ppsp->lParam;
  1431. return TRUE;
  1432. }
  1433. break;
  1434. case WM_NOTIFY:
  1435. {
  1436. LPNMHDR lpnmhdr = (LPNMHDR) lParam;
  1437. Assert( lpc );
  1438. switch( lpnmhdr->code )
  1439. {
  1440. case PSN_SETACTIVE:
  1441. TraceMsg( TF_WM, "PSN_SETACTIVE\n" );
  1442. if ( !lpc->_fAddSif || !lpc->_fCopyFromLocation )
  1443. {
  1444. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  1445. return TRUE;
  1446. }
  1447. else
  1448. {
  1449. ULONG uLength =
  1450. Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_FILEPATH ) );
  1451. if ( !uLength )
  1452. {
  1453. PropSheet_SetWizButtons( GetParent( hDlg ),
  1454. PSWIZB_BACK );
  1455. }
  1456. else
  1457. {
  1458. PropSheet_SetWizButtons( GetParent( hDlg ),
  1459. PSWIZB_BACK | PSWIZB_NEXT );
  1460. }
  1461. }
  1462. break;
  1463. case PSN_WIZNEXT:
  1464. TraceMsg( TF_WM, "PSN_WIZNEXT\n" );
  1465. {
  1466. HWND hwndEdit = GetDlgItem( hDlg, IDC_E_FILEPATH );
  1467. ULONG uLength = Edit_GetTextLength( hwndEdit );
  1468. DWORD dw;
  1469. Assert( uLength );
  1470. uLength++; // add one for the NULL
  1471. // if we had a previous buffer allocated,
  1472. // see if we can reuse it
  1473. if ( lpc->_pszSourcePath && uLength
  1474. > wcslen(lpc->_pszSourcePath) + 1 )
  1475. {
  1476. TraceFree( lpc->_pszSourcePath );
  1477. lpc->_pszSourcePath = NULL;
  1478. }
  1479. if ( lpc->_pszSourceImage
  1480. && lpc->_pszSourceImage != lpc->_szNA
  1481. && lpc->_pszSourceImage != lpc->_szLocation )
  1482. TraceFree( lpc->_pszSourceImage );
  1483. // no need to NULL since it is set below
  1484. lpc->_pszSourceImage = lpc->_szLocation;
  1485. if ( !lpc->_pszSourcePath )
  1486. {
  1487. lpc->_pszSourcePath =
  1488. (LPWSTR) TraceAllocString( LMEM_FIXED, uLength );
  1489. if ( !lpc->_pszSourcePath )
  1490. {
  1491. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't change
  1492. return TRUE;
  1493. }
  1494. }
  1495. Edit_GetText( hwndEdit, lpc->_pszSourcePath, uLength );
  1496. DWORD dwAttrs = GetFileAttributes( lpc->_pszSourcePath );
  1497. if ( dwAttrs == 0xFFFFffff )
  1498. { // file doesn't exist
  1499. DWORD dwErr = GetLastError( );
  1500. MessageBoxFromError( hDlg, NULL, dwErr );
  1501. TraceFree( lpc->_pszSourcePath );
  1502. lpc->_pszSourcePath = NULL;
  1503. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't continue
  1504. return TRUE;
  1505. }
  1506. else
  1507. { // the SIF image must be a "FLAT" image
  1508. WCHAR szImageType[ 40 ];
  1509. GetPrivateProfileString( OSCHOOSER_SIF_SECTION,
  1510. OSCHOOSER_IMAGETYPE_ENTRY,
  1511. L"",
  1512. szImageType,
  1513. ARRAYSIZE(szImageType),
  1514. lpc->_pszSourcePath );
  1515. if ( StrCmpI( szImageType, OSCHOOSER_IMAGETYPE_FLAT ) )
  1516. {
  1517. MessageBoxFromStrings( hDlg,
  1518. IDS_MUST_BE_FLAT_CAPTION,
  1519. IDS_MUST_BE_FLAT_TEXT,
  1520. MB_OK );
  1521. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't continue
  1522. return TRUE;
  1523. }
  1524. GetPrivateProfileString( OSCHOOSER_SIF_SECTION,
  1525. OSCHOOSER_DESCRIPTION_ENTRY,
  1526. L"",
  1527. lpc->_szDescription,
  1528. ARRAYSIZE(lpc->_szDescription),
  1529. lpc->_pszSourcePath );
  1530. GetPrivateProfileString( OSCHOOSER_SIF_SECTION,
  1531. OSCHOOSER_HELPTEXT_ENTRY,
  1532. L"",
  1533. lpc->_szHelpText,
  1534. ARRAYSIZE(lpc->_szHelpText),
  1535. lpc->_pszSourcePath );
  1536. }
  1537. }
  1538. break;
  1539. case PSN_QUERYCANCEL:
  1540. TraceMsg( TF_WM, "PSN_QUERYCANCEL\n" );
  1541. return lpc->_VerifyCancel( hDlg );
  1542. }
  1543. }
  1544. break;
  1545. case WM_COMMAND:
  1546. TraceMsg( TF_WM, "WM_COMMAND\n" );
  1547. HWND hwnd = (HWND) lParam;
  1548. switch ( LOWORD( wParam ) )
  1549. {
  1550. case IDC_E_FILEPATH:
  1551. if ( HIWORD( wParam ) == EN_CHANGE )
  1552. {
  1553. LONG uLength = Edit_GetTextLength( hwnd );
  1554. if ( !uLength )
  1555. {
  1556. PropSheet_SetWizButtons( GetParent( hDlg ),
  1557. PSWIZB_BACK );
  1558. }
  1559. else
  1560. {
  1561. PropSheet_SetWizButtons( GetParent( hDlg ),
  1562. PSWIZB_BACK | PSWIZB_NEXT );
  1563. }
  1564. return TRUE;
  1565. }
  1566. break;
  1567. case IDC_B_BROWSE:
  1568. if ( HIWORD( wParam ) == BN_CLICKED )
  1569. {
  1570. WCHAR szFilter[ 80 ]; // random
  1571. WCHAR szFilepath[ MAX_PATH ] = { L'\0' }; // bigger?
  1572. WCHAR szSIF[ ] = { L"SIF" };
  1573. DWORD dw;
  1574. OPENFILENAME ofn;
  1575. // Build OpenFileName dialogs filter
  1576. ZeroMemory( szFilter, sizeof(szFilter) );
  1577. dw = LoadString( g_hInstance,
  1578. IDS_OFN_SIF_FILTER,
  1579. szFilter,
  1580. ARRAYSIZE(szFilter) );
  1581. Assert( dw );
  1582. dw++; // include NULL character
  1583. wcscat( &szFilter[dw], L"*.SIF" );
  1584. #ifdef DEBUG
  1585. // paranoid... make sure it fits!
  1586. dw += wcslen( &szFilter[dw] ) + 2; // +2 = one for each NULL character
  1587. Assert( dw + 2 <= sizeof(szFilter) );
  1588. #endif // DEBUG
  1589. // Build OpenFileName structure
  1590. ZeroMemory( &ofn, sizeof(ofn) );
  1591. ofn.lStructSize = sizeof(ofn);
  1592. ofn.hwndOwner = hDlg;
  1593. ofn.hInstance = g_hInstance;
  1594. ofn.lpstrFilter = szFilter;
  1595. ofn.lpstrFile = szFilepath;
  1596. ofn.nMaxFile = ARRAYSIZE(szFilepath);
  1597. ofn.Flags = OFN_ENABLESIZING | OFN_FILEMUSTEXIST
  1598. | OFN_HIDEREADONLY;
  1599. ofn.lpstrDefExt = szSIF;
  1600. if ( GetOpenFileName( &ofn ) )
  1601. {
  1602. SetDlgItemText( hDlg, IDC_E_FILEPATH, szFilepath );
  1603. return TRUE;
  1604. }
  1605. }
  1606. break;
  1607. }
  1608. break;
  1609. }
  1610. return FALSE;
  1611. }
  1612. //
  1613. // Page6DlgProc( )
  1614. //
  1615. INT_PTR CALLBACK
  1616. THISCLASS::Page6DlgProc(
  1617. HWND hDlg,
  1618. UINT uMsg,
  1619. WPARAM wParam,
  1620. LPARAM lParam )
  1621. {
  1622. LPTHISCLASS lpc = (LPTHISCLASS) GetWindowLongPtr( hDlg, GWLP_USERDATA );
  1623. switch ( uMsg )
  1624. {
  1625. case WM_INITDIALOG:
  1626. TraceMsg( TF_WM, "WM_INITDIALOG\n" );
  1627. {
  1628. LPPROPSHEETPAGE ppsp = (LPPROPSHEETPAGE) lParam;
  1629. Assert( ppsp );
  1630. Assert( ppsp->lParam );
  1631. SetWindowLongPtr( hDlg, GWLP_USERDATA, ppsp->lParam );
  1632. lpc = (LPTHISCLASS) ppsp->lParam;
  1633. THR( lpc->_InitListView( GetDlgItem( hDlg, IDC_L_OSES ), FALSE ) );
  1634. return TRUE;
  1635. }
  1636. break;
  1637. case WM_NOTIFY:
  1638. {
  1639. LPNMHDR lpnmhdr = (LPNMHDR) lParam;
  1640. Assert( lpc );
  1641. switch( lpnmhdr->code )
  1642. {
  1643. case PSN_SETACTIVE:
  1644. TraceMsg( TF_WM, "PSN_SETACTIVE\n" );
  1645. if ( !lpc->_fAddSif )
  1646. {
  1647. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  1648. return TRUE;
  1649. }
  1650. Assert( lpc->_pszServerName );
  1651. if ( lpc->_pszServerName )
  1652. {
  1653. LPWSTR pszStartPath =
  1654. (LPWSTR) TraceAllocString( LMEM_FIXED,
  1655. wcslen( lpc->_pszServerName )
  1656. + ARRAYSIZE(SERVER_START_STRING) );
  1657. if ( pszStartPath )
  1658. {
  1659. wsprintf( pszStartPath,
  1660. SERVER_START_STRING,
  1661. lpc->_pszServerName );
  1662. lpc->_hDlg = hDlg;
  1663. lpc->_hwndList = GetDlgItem( hDlg, IDC_L_OSES );
  1664. lpc->_PopulateImageListView( pszStartPath );
  1665. TraceFree( pszStartPath );
  1666. }
  1667. }
  1668. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK );
  1669. break;
  1670. case PSN_WIZNEXT:
  1671. TraceMsg( TF_WM, "PSN_WIZNEXT\n" );
  1672. {
  1673. LVITEM lvi;
  1674. HWND hwndList = GetDlgItem( hDlg, IDC_L_OSES );
  1675. lvi.iItem = ListView_GetNextItem( hwndList, -1, LVNI_SELECTED );
  1676. Assert( lvi.iItem != -1 );
  1677. lvi.iSubItem = 0;
  1678. lvi.mask = LVIF_PARAM;
  1679. ListView_GetItem( hwndList, &lvi );
  1680. Assert(lvi.lParam);
  1681. LPSIFINFO pSIF = (LPSIFINFO) lvi.lParam;
  1682. if ( lpc->_pszDestPath)
  1683. TraceFree( lpc->_pszDestPath );
  1684. // no need to NULL - it set again below
  1685. lpc->_pszDestPath =
  1686. (LPWSTR) TraceAllocString( LMEM_FIXED,
  1687. wcslen( pSIF->pszFilePath )
  1688. + ARRAYSIZE(SLASH_TEMPLATES) );
  1689. if ( !lpc->_pszDestPath )
  1690. {
  1691. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't continue;
  1692. return TRUE;
  1693. }
  1694. wcscpy( lpc->_pszDestPath, pSIF->pszFilePath );
  1695. wcscat( lpc->_pszDestPath, SLASH_TEMPLATES );
  1696. lpc->_fDestPathIncludesSIF = FALSE;
  1697. if ( lpc->_pszDestImage
  1698. && lpc->_pszDestImage != lpc->_szNA )
  1699. TraceFree( lpc->_pszDestImage );
  1700. // no need to NULL - it set again below
  1701. lpc->_pszDestImage = pSIF->pszImageFile;
  1702. pSIF->pszImageFile = NULL; // don't free this
  1703. ListView_DeleteAllItems( hwndList );
  1704. }
  1705. break;
  1706. case PSN_QUERYCANCEL:
  1707. TraceMsg( TF_WM, "PSN_QUERYCANCEL\n" );
  1708. return lpc->_VerifyCancel( hDlg );
  1709. case LVN_DELETEALLITEMS:
  1710. TraceMsg( TF_WM, "LVN_DELETEALLITEMS - Deleting all items.\n" );
  1711. break;
  1712. case LVN_DELETEITEM:
  1713. TraceMsg( TF_WM, "LVN_DELETEITEM - Deleting an item.\n" );
  1714. {
  1715. LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;
  1716. LPSIFINFO pSIF = (LPSIFINFO) pnmv->lParam;
  1717. THR( lpc->_CleanupSIFInfo( pSIF ) );
  1718. }
  1719. break;
  1720. case LVN_ITEMCHANGED:
  1721. {
  1722. HWND hwndList = GetDlgItem( hDlg, IDC_L_OSES );
  1723. UINT iItems =
  1724. ListView_GetNextItem( hwndList, -1, LVNI_SELECTED );
  1725. if ( iItems != -1 )
  1726. {
  1727. PropSheet_SetWizButtons( GetParent( hDlg ),
  1728. PSWIZB_BACK | PSWIZB_NEXT );
  1729. }
  1730. else
  1731. {
  1732. PropSheet_SetWizButtons( GetParent( hDlg ),
  1733. PSWIZB_BACK );
  1734. }
  1735. }
  1736. break;
  1737. }
  1738. }
  1739. break;
  1740. }
  1741. return FALSE;
  1742. }
  1743. //
  1744. // Page7DlgProc( )
  1745. //
  1746. INT_PTR CALLBACK
  1747. THISCLASS::Page7DlgProc(
  1748. HWND hDlg,
  1749. UINT uMsg,
  1750. WPARAM wParam,
  1751. LPARAM lParam )
  1752. {
  1753. LPTHISCLASS lpc = (LPTHISCLASS) GetWindowLongPtr( hDlg, GWLP_USERDATA );
  1754. switch ( uMsg )
  1755. {
  1756. case WM_INITDIALOG:
  1757. TraceMsg( TF_WM, "WM_INITDIALOG\n" );
  1758. {
  1759. LPPROPSHEETPAGE ppsp = (LPPROPSHEETPAGE) lParam;
  1760. Assert( ppsp );
  1761. Assert( ppsp->lParam );
  1762. SetWindowLongPtr( hDlg, GWLP_USERDATA, ppsp->lParam );
  1763. lpc = (LPTHISCLASS) ppsp->lParam;
  1764. THR( lpc->_InitListView( GetDlgItem( hDlg, IDC_L_SIFS ), FALSE ) );
  1765. return TRUE;
  1766. }
  1767. break;
  1768. case WM_NOTIFY:
  1769. {
  1770. LPNMHDR lpnmhdr = (LPNMHDR) lParam;
  1771. Assert( lpc );
  1772. switch( lpnmhdr->code )
  1773. {
  1774. case PSN_SETACTIVE:
  1775. TraceMsg( TF_WM, "PSN_SETACTIVE\n" );
  1776. if ( !lpc->_fAddSif || !lpc->_fCopyFromSamples )
  1777. {
  1778. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  1779. return TRUE;
  1780. }
  1781. Assert( lpc->_pszDestPath );
  1782. if ( lpc->_pszDestPath )
  1783. {
  1784. LPWSTR pszStartPath =
  1785. (LPWSTR) TraceStrDup( lpc->_pszDestPath );
  1786. if ( pszStartPath )
  1787. {
  1788. // remove the "\templates" from the path
  1789. LPWSTR psz = StrRChr( pszStartPath,
  1790. &pszStartPath[wcslen(pszStartPath)],
  1791. L'\\' );
  1792. Assert( psz );
  1793. if ( psz )
  1794. {
  1795. *psz = L'\0'; // terminate
  1796. lpc->_hDlg = hDlg;
  1797. lpc->_hwndList = GetDlgItem( hDlg, IDC_L_SIFS );
  1798. lpc->_PopulateSamplesListView( pszStartPath );
  1799. *psz = L'\\'; // restore
  1800. }
  1801. TraceFree( pszStartPath );
  1802. }
  1803. }
  1804. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK );
  1805. break;
  1806. case PSN_WIZNEXT:
  1807. TraceMsg( TF_WM, "PSN_WIZNEXT\n" );
  1808. {
  1809. LVITEM lvi;
  1810. DWORD dw;
  1811. HWND hwndList = GetDlgItem( hDlg, IDC_L_SIFS );
  1812. lvi.iItem = ListView_GetNextItem( hwndList, -1, LVNI_SELECTED );
  1813. Assert( lvi.iItem != -1 );
  1814. lvi.iSubItem = 0;
  1815. lvi.mask = LVIF_PARAM;
  1816. ListView_GetItem( hwndList, &lvi );
  1817. Assert(lvi.lParam);
  1818. LPSIFINFO pSIF = (LPSIFINFO) lvi.lParam;
  1819. if ( lpc->_pszSourcePath )
  1820. TraceFree( lpc->_pszSourcePath );
  1821. // no need to NULL - it is set again below
  1822. if ( lpc->_pszSourceImage
  1823. && lpc->_pszSourceImage != lpc->_szNA
  1824. && lpc->_pszSourceImage != lpc->_szLocation )
  1825. TraceFree( lpc->_pszSourceImage );
  1826. // no need to NULL since it is set below
  1827. lpc->_pszSourcePath = pSIF->pszFilePath;
  1828. lpc->_pszSourceImage = pSIF->pszImageFile;
  1829. if ( pSIF->pszDescription )
  1830. {
  1831. wcscpy( lpc->_szDescription, pSIF->pszDescription );
  1832. }
  1833. else
  1834. {
  1835. lpc->_szDescription[0] = L'\0';
  1836. }
  1837. if ( pSIF->pszHelpText )
  1838. {
  1839. wcscpy( lpc->_szHelpText, pSIF->pszHelpText );
  1840. }
  1841. else
  1842. {
  1843. lpc->_szHelpText[0] = L'\0';
  1844. }
  1845. pSIF->pszFilePath = NULL; // don't free this, we're using it
  1846. pSIF->pszImageFile = NULL; // don't free this, we're using it
  1847. ListView_DeleteAllItems( hwndList );
  1848. }
  1849. break;
  1850. case PSN_QUERYCANCEL:
  1851. TraceMsg( TF_WM, "PSN_QUERYCANCEL\n" );
  1852. return lpc->_VerifyCancel( hDlg );
  1853. case LVN_DELETEALLITEMS:
  1854. TraceMsg( TF_WM, "LVN_DELETEALLITEMS - Deleting all items.\n" );
  1855. break;
  1856. case LVN_DELETEITEM:
  1857. TraceMsg( TF_WM, "LVN_DELETEITEM - Deleting an item.\n" );
  1858. {
  1859. LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;
  1860. LPSIFINFO pSIF = (LPSIFINFO) pnmv->lParam;
  1861. THR( lpc->_CleanupSIFInfo( pSIF ) );
  1862. }
  1863. break;
  1864. case LVN_ITEMCHANGED:
  1865. {
  1866. HWND hwndList = GetDlgItem( hDlg, IDC_L_SIFS );
  1867. UINT iItems = ListView_GetNextItem( hwndList, -1, LVNI_SELECTED );
  1868. if ( iItems != -1 )
  1869. {
  1870. PropSheet_SetWizButtons( GetParent( hDlg ),
  1871. PSWIZB_BACK | PSWIZB_NEXT );
  1872. }
  1873. else
  1874. {
  1875. PropSheet_SetWizButtons( GetParent( hDlg ),
  1876. PSWIZB_BACK );
  1877. }
  1878. }
  1879. break;
  1880. }
  1881. }
  1882. break;
  1883. }
  1884. return FALSE;
  1885. }
  1886. //
  1887. // Page8DlgProc( )
  1888. //
  1889. INT_PTR CALLBACK
  1890. THISCLASS::Page8DlgProc(
  1891. HWND hDlg,
  1892. UINT uMsg,
  1893. WPARAM wParam,
  1894. LPARAM lParam )
  1895. {
  1896. LPTHISCLASS lpc = (LPTHISCLASS) GetWindowLongPtr( hDlg, GWLP_USERDATA );
  1897. switch ( uMsg )
  1898. {
  1899. case WM_INITDIALOG:
  1900. TraceMsg( TF_WM, "WM_INITDIALOG\n" );
  1901. {
  1902. LPPROPSHEETPAGE ppsp = (LPPROPSHEETPAGE) lParam;
  1903. Assert( ppsp );
  1904. Assert( ppsp->lParam );
  1905. SetWindowLongPtr( hDlg, GWLP_USERDATA, ppsp->lParam );
  1906. // lpc = (LPTHISCLASS) ppsp->lParam;
  1907. return TRUE;
  1908. }
  1909. break;
  1910. case WM_NOTIFY:
  1911. {
  1912. LPNMHDR lpnmhdr = (LPNMHDR) lParam;
  1913. Assert( lpc );
  1914. switch( lpnmhdr->code )
  1915. {
  1916. case PSN_SETACTIVE:
  1917. TraceMsg( TF_WM, "PSN_SETACTIVE\n" );
  1918. if ( !lpc->_fAddSif )
  1919. {
  1920. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  1921. return TRUE;
  1922. }
  1923. else
  1924. {
  1925. Assert( lpc->_pszSourcePath );
  1926. Assert( lpc->_pszDestPath );
  1927. LPWSTR pszDestFilePath;
  1928. ULONG uDestLength = wcslen( lpc->_pszDestPath );
  1929. LPWSTR pszFilename;
  1930. lpc->_fSIFCanExist = FALSE; // reset
  1931. if ( lpc->_fDestPathIncludesSIF )
  1932. { // strip the filename
  1933. LPWSTR psz = StrRChr( lpc->_pszDestPath,
  1934. &lpc->_pszDestPath[ uDestLength ],
  1935. L'\\' );
  1936. Assert(psz);
  1937. *psz = L'\0'; // truncate
  1938. lpc->_fDestPathIncludesSIF = FALSE;
  1939. if ( !lpc->_fShowedPage8 )
  1940. {
  1941. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  1942. return TRUE;
  1943. }
  1944. psz++;
  1945. pszFilename = psz;
  1946. }
  1947. else
  1948. {
  1949. pszFilename =
  1950. StrRChr( lpc->_pszSourcePath,
  1951. &lpc->_pszSourcePath[wcslen(lpc->_pszSourcePath)],
  1952. L'\\' );
  1953. Assert( pszFilename );
  1954. pszFilename++; // move past the '\'
  1955. pszDestFilePath =
  1956. (LPWSTR) TraceAllocString( LMEM_FIXED,
  1957. uDestLength + 1
  1958. + wcslen( pszFilename ) + 1 );
  1959. if ( pszDestFilePath )
  1960. {
  1961. wcscpy( pszDestFilePath, lpc->_pszDestPath );
  1962. wcscat( pszDestFilePath, L"\\" );
  1963. wcscat( pszDestFilePath, pszFilename );
  1964. DWORD dwAttrs = GetFileAttributes( pszDestFilePath );
  1965. if ( dwAttrs == 0xFFFFffff )
  1966. { // file does not exist on destination server.
  1967. // Use the same SIF as the source.
  1968. TraceFree( lpc->_pszDestPath );
  1969. lpc->_pszDestPath = pszDestFilePath;
  1970. lpc->_fDestPathIncludesSIF = TRUE;
  1971. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  1972. return TRUE;
  1973. }
  1974. TraceFree( pszDestFilePath );
  1975. }
  1976. // else be paranoid and prompt for a name
  1977. }
  1978. HWND hwnd = GetDlgItem( hDlg, IDC_E_FILENAME );
  1979. Edit_LimitText( hwnd, 128 - uDestLength );
  1980. Edit_SetText( hwnd, pszFilename );
  1981. lpc->_fShowedPage8 = TRUE;
  1982. }
  1983. break;
  1984. case PSN_WIZBACK:
  1985. lpc->_fShowedPage8 = FALSE; // reset this
  1986. break;
  1987. case PSN_WIZNEXT:
  1988. TraceMsg( TF_WM, "PSN_WIZNEXT\n" );
  1989. {
  1990. Assert( lpc->_pszDestPath );
  1991. Assert( !lpc->_fDestPathIncludesSIF );
  1992. HWND hwndEdit = GetDlgItem( hDlg, IDC_E_FILENAME );
  1993. ULONG uLength = Edit_GetTextLength( hwndEdit );
  1994. ULONG uLengthDest = wcslen( lpc->_pszDestPath );
  1995. DWORD dwAttrs;
  1996. Assert( uLength );
  1997. AssertMsg( uLengthDest + uLength <= 128,
  1998. "The Edit_LimitText() should prevent this from happening." );
  1999. uLength++; // add one for the NULL
  2000. LPWSTR pszNewDestPath =
  2001. (LPWSTR) TraceAllocString( LMEM_FIXED,
  2002. uLengthDest + 1 + uLength );
  2003. if ( !pszNewDestPath )
  2004. goto PSN_WIZNEXT_Abort;
  2005. wcscpy( pszNewDestPath, lpc->_pszDestPath );
  2006. wcscat( pszNewDestPath, L"\\" );
  2007. Edit_GetText( hwndEdit, &pszNewDestPath[uLengthDest + 1], uLength );
  2008. if ( !VerifySIFText( pszNewDestPath )
  2009. || StrChr( pszNewDestPath, 32 ) != NULL ) // no spaces!
  2010. {
  2011. MessageBoxFromStrings( hDlg,
  2012. IDS_OSCHOOSER_DIRECTORY_RESTRICTION_TITLE,
  2013. IDS_OSCHOOSER_DIRECTORY_RESTRICTION_TEXT,
  2014. MB_OK );
  2015. goto PSN_WIZNEXT_Abort;
  2016. }
  2017. // make sure it doesn't exist.
  2018. dwAttrs = GetFileAttributes( pszNewDestPath );
  2019. if ( dwAttrs != 0xFFFFffff )
  2020. { // file exists, verify with user to overwrite
  2021. UINT i = MessageBoxFromStrings( hDlg,
  2022. IDS_OVERWRITE_CAPTION,
  2023. IDS_OVERWRITE_TEXT,
  2024. MB_YESNO );
  2025. if ( i == IDNO )
  2026. {
  2027. goto PSN_WIZNEXT_Abort;
  2028. }
  2029. else
  2030. {
  2031. lpc->_fSIFCanExist = TRUE;
  2032. }
  2033. }
  2034. uLength = wcslen( pszNewDestPath );
  2035. if ( StrCmpI( &pszNewDestPath[ uLength - 4 ], L".SIF" ) != 0 )
  2036. {
  2037. UINT i = MessageBoxFromStrings( hDlg,
  2038. IDC_IMPROPER_EXTENSION_CAPTION,
  2039. IDC_IMPROPER_EXTENSION_TEXT,
  2040. MB_YESNO );
  2041. if ( i == IDNO )
  2042. goto PSN_WIZNEXT_Abort;
  2043. }
  2044. TraceFree( lpc->_pszDestPath );
  2045. lpc->_pszDestPath = pszNewDestPath;
  2046. lpc->_fDestPathIncludesSIF = TRUE;
  2047. return FALSE; // do it
  2048. PSN_WIZNEXT_Abort:
  2049. if ( pszNewDestPath )
  2050. TraceFree( pszNewDestPath );
  2051. // no need to NULL, going out of scope
  2052. SetFocus( hwndEdit );
  2053. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't continue
  2054. return TRUE;
  2055. }
  2056. break;
  2057. case PSN_QUERYCANCEL:
  2058. TraceMsg( TF_WM, "PSN_QUERYCANCEL\n" );
  2059. return lpc->_VerifyCancel( hDlg );
  2060. }
  2061. }
  2062. break;
  2063. case WM_COMMAND:
  2064. TraceMsg( TF_WM, "WM_COMMAND\n" );
  2065. HWND hwnd = (HWND) lParam;
  2066. switch ( LOWORD( wParam ) )
  2067. {
  2068. case IDC_E_FILENAME:
  2069. if ( HIWORD( wParam ) == EN_CHANGE )
  2070. {
  2071. LONG uLength = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_FILENAME ) );
  2072. if ( !uLength )
  2073. {
  2074. PropSheet_SetWizButtons( GetParent( hDlg ),
  2075. PSWIZB_BACK );
  2076. }
  2077. else
  2078. {
  2079. PropSheet_SetWizButtons( GetParent( hDlg ),
  2080. PSWIZB_BACK | PSWIZB_NEXT );
  2081. }
  2082. return TRUE;
  2083. }
  2084. break;
  2085. }
  2086. break;
  2087. }
  2088. return FALSE;
  2089. }
  2090. //
  2091. // Page9DlgProc( )
  2092. //
  2093. INT_PTR CALLBACK
  2094. THISCLASS::Page9DlgProc(
  2095. HWND hDlg,
  2096. UINT uMsg,
  2097. WPARAM wParam,
  2098. LPARAM lParam )
  2099. {
  2100. LPTHISCLASS lpc = (LPTHISCLASS) GetWindowLongPtr( hDlg, GWLP_USERDATA );
  2101. switch ( uMsg )
  2102. {
  2103. case WM_INITDIALOG:
  2104. TraceMsg( TF_WM, "WM_INITDIALOG\n" );
  2105. {
  2106. LPPROPSHEETPAGE ppsp = (LPPROPSHEETPAGE) lParam;
  2107. Assert( ppsp );
  2108. Assert( ppsp->lParam );
  2109. SetWindowLongPtr( hDlg, GWLP_USERDATA, ppsp->lParam );
  2110. Edit_LimitText( GetDlgItem( hDlg, IDC_E_DESCRIPTION ),
  2111. ARRAYSIZE(lpc->_szDescription) - 1 );
  2112. Edit_LimitText( GetDlgItem( hDlg, IDC_E_HELPTEXT),
  2113. ARRAYSIZE(lpc->_szHelpText) - 1 );
  2114. // lpc = (LPTHISCLASS) ppsp->lParam;
  2115. return TRUE;
  2116. }
  2117. break;
  2118. case WM_NOTIFY:
  2119. {
  2120. LPNMHDR lpnmhdr = (LPNMHDR) lParam;
  2121. Assert( lpc );
  2122. switch( lpnmhdr->code )
  2123. {
  2124. case PSN_SETACTIVE:
  2125. TraceMsg( TF_WM, "PSN_SETACTIVE\n" );
  2126. if ( !lpc->_fAddSif )
  2127. {
  2128. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  2129. return TRUE;
  2130. }
  2131. else
  2132. {
  2133. Assert( lpc->_pszSourcePath );
  2134. SetDlgItemText( hDlg, IDC_E_DESCRIPTION, lpc->_szDescription);
  2135. SetDlgItemText( hDlg, IDC_E_HELPTEXT, lpc->_szHelpText );
  2136. if ( !Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_DESCRIPTION ) )
  2137. || !Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_HELPTEXT ) ) )
  2138. {
  2139. PropSheet_SetWizButtons( GetParent( hDlg ),
  2140. PSWIZB_BACK );
  2141. }
  2142. else
  2143. {
  2144. PropSheet_SetWizButtons( GetParent( hDlg ),
  2145. PSWIZB_BACK | PSWIZB_NEXT );
  2146. }
  2147. }
  2148. break;
  2149. case PSN_WIZNEXT:
  2150. TraceMsg( TF_WM, "PSN_WIZNEXT\n" );
  2151. {
  2152. GetDlgItemText( hDlg,
  2153. IDC_E_DESCRIPTION,
  2154. lpc->_szDescription,
  2155. ARRAYSIZE(lpc->_szDescription) );
  2156. GetDlgItemText( hDlg,
  2157. IDC_E_HELPTEXT,
  2158. lpc->_szHelpText,
  2159. ARRAYSIZE(lpc->_szHelpText) );
  2160. if ( !VerifySIFText( lpc->_szDescription ) )
  2161. {
  2162. MessageBoxFromStrings( hDlg,
  2163. IDS_OSCHOOSER_RESTRICTION_FIELDS_TITLE,
  2164. IDS_OSCHOOSER_RESTRICTION_FIELDS_TEXT,
  2165. MB_OK );
  2166. SetFocus( GetDlgItem( hDlg, IDC_E_DESCRIPTION ) );
  2167. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't change
  2168. return TRUE;
  2169. }
  2170. if ( !VerifySIFText( lpc->_szHelpText ) )
  2171. {
  2172. MessageBoxFromStrings( hDlg,
  2173. IDS_OSCHOOSER_RESTRICTION_FIELDS_TITLE,
  2174. IDS_OSCHOOSER_RESTRICTION_FIELDS_TEXT,
  2175. MB_OK );
  2176. SetFocus( GetDlgItem( hDlg, IDC_E_HELPTEXT ) );
  2177. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't change
  2178. return TRUE;
  2179. }
  2180. }
  2181. break;
  2182. case PSN_QUERYCANCEL:
  2183. TraceMsg( TF_WM, "PSN_QUERYCANCEL\n" );
  2184. return lpc->_VerifyCancel( hDlg );
  2185. }
  2186. }
  2187. break;
  2188. case WM_COMMAND:
  2189. TraceMsg( TF_WM, "WM_COMMAND\n" );
  2190. switch ( LOWORD( wParam ) )
  2191. {
  2192. case IDC_E_DESCRIPTION:
  2193. case IDC_E_HELPTEXT:
  2194. if ( HIWORD( wParam ) == EN_CHANGE )
  2195. {
  2196. if ( !Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_DESCRIPTION ) )
  2197. || !Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_HELPTEXT ) ) )
  2198. {
  2199. PropSheet_SetWizButtons( GetParent( hDlg ),
  2200. PSWIZB_BACK );
  2201. }
  2202. else
  2203. {
  2204. PropSheet_SetWizButtons( GetParent( hDlg ),
  2205. PSWIZB_BACK | PSWIZB_NEXT );
  2206. }
  2207. return TRUE;
  2208. }
  2209. break;
  2210. }
  2211. break;
  2212. }
  2213. return FALSE;
  2214. }
  2215. //
  2216. // Page10DlgProc( )
  2217. //
  2218. INT_PTR CALLBACK
  2219. THISCLASS::Page10DlgProc(
  2220. HWND hDlg,
  2221. UINT uMsg,
  2222. WPARAM wParam,
  2223. LPARAM lParam )
  2224. {
  2225. LPTHISCLASS lpc = (LPTHISCLASS) GetWindowLongPtr( hDlg, GWLP_USERDATA );
  2226. switch ( uMsg )
  2227. {
  2228. case WM_INITDIALOG:
  2229. TraceMsg( TF_WM, "WM_INITDIALOG\n" );
  2230. {
  2231. LPPROPSHEETPAGE ppsp = (LPPROPSHEETPAGE) lParam;
  2232. Assert( ppsp );
  2233. Assert( ppsp->lParam );
  2234. SetWindowLongPtr( hDlg, GWLP_USERDATA, ppsp->lParam );
  2235. // lpc = (LPTHISCLASS) ppsp->lParam;
  2236. return TRUE;
  2237. }
  2238. break;
  2239. case WM_NOTIFY:
  2240. {
  2241. LPNMHDR lpnmhdr = (LPNMHDR) lParam;
  2242. Assert( lpc );
  2243. switch( lpnmhdr->code )
  2244. {
  2245. case PSN_SETACTIVE:
  2246. TraceMsg( TF_WM, "PSN_SETACTIVE\n" );
  2247. if ( !lpc->_fAddSif )
  2248. {
  2249. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  2250. return TRUE;
  2251. }
  2252. else
  2253. {
  2254. WCHAR szTemp[ MAX_PATH ];
  2255. RECT rect;
  2256. Assert( lpc->_pszSourcePath );
  2257. Assert( lpc->_pszDestPath );
  2258. Assert( lpc->_pszSourceImage );
  2259. Assert( lpc->_pszDestImage );
  2260. SetDlgItemText( hDlg, IDC_E_SOURCE, lpc->_pszSourcePath );
  2261. wcscpy( szTemp, lpc->_pszSourceImage );
  2262. GetWindowRect( GetDlgItem( hDlg, IDC_S_SOURCEIMAGE ), &rect );
  2263. PathCompactPath( NULL, szTemp, rect.right - rect.left );
  2264. SetDlgItemText( hDlg, IDC_S_SOURCEIMAGE, szTemp );
  2265. SetDlgItemText( hDlg, IDC_E_DESTINATION, lpc->_pszDestPath );
  2266. wcscpy( szTemp, lpc->_pszDestImage );
  2267. GetWindowRect( GetDlgItem( hDlg, IDC_S_DESTIMAGE ), &rect );
  2268. PathCompactPath( NULL, szTemp, rect.right - rect.left );
  2269. SetDlgItemText( hDlg, IDC_S_DESTIMAGE, szTemp );
  2270. PropSheet_SetWizButtons( GetParent( hDlg ),
  2271. PSWIZB_BACK | PSWIZB_FINISH );
  2272. }
  2273. break;
  2274. case PSN_WIZFINISH:
  2275. TraceMsg( TF_WM, "PSN_WIZFINISH\n" );
  2276. Assert( lpc->_pszSourcePath );
  2277. Assert( lpc->_pszDestPath );
  2278. Assert( wcslen( lpc->_pszSourcePath ) <= MAX_PATH );
  2279. Assert( wcslen( lpc->_pszDestPath ) <= MAX_PATH );
  2280. if ( !CopyFile( lpc->_pszSourcePath, lpc->_pszDestPath, !lpc->_fSIFCanExist ) )
  2281. {
  2282. DWORD dwErr = GetLastError( );
  2283. MessageBoxFromError( hDlg, IDS_ERROR_COPYING_FILE, dwErr );
  2284. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't continue;
  2285. return TRUE;
  2286. }
  2287. else
  2288. {
  2289. WCHAR szTemp[ REMOTE_INSTALL_MAX_HELPTEXT_CHAR_COUNT + 2 ];
  2290. Assert( REMOTE_INSTALL_MAX_DESCRIPTION_CHAR_COUNT
  2291. < REMOTE_INSTALL_MAX_HELPTEXT_CHAR_COUNT );
  2292. wsprintf( szTemp, L"\"%s\"", lpc->_szDescription );
  2293. WritePrivateProfileString( OSCHOOSER_SIF_SECTION,
  2294. OSCHOOSER_DESCRIPTION_ENTRY,
  2295. szTemp,
  2296. lpc->_pszDestPath );
  2297. wsprintf( szTemp, L"\"%s\"", lpc->_szHelpText );
  2298. WritePrivateProfileString( OSCHOOSER_SIF_SECTION,
  2299. OSCHOOSER_HELPTEXT_ENTRY,
  2300. szTemp,
  2301. lpc->_pszDestPath );
  2302. }
  2303. break;
  2304. case PSN_QUERYCANCEL:
  2305. TraceMsg( TF_WM, "PSN_QUERYCANCEL\n" );
  2306. return lpc->_VerifyCancel( hDlg );
  2307. }
  2308. }
  2309. break;
  2310. }
  2311. return FALSE;
  2312. }
  2313. //
  2314. // Verifies that the user wanted to cancel setup.
  2315. //
  2316. INT
  2317. THISCLASS::_VerifyCancel( HWND hParent )
  2318. {
  2319. TraceClsFunc( "_VerifyCancel( ... )\n" );
  2320. INT iReturn;
  2321. BOOL fAbort = FALSE;
  2322. iReturn = MessageBoxFromStrings( hParent,
  2323. IDS_CANCELCAPTION,
  2324. IDS_CANCELTEXT,
  2325. MB_YESNO | MB_ICONQUESTION );
  2326. if ( iReturn == IDYES ) {
  2327. fAbort = TRUE;
  2328. }
  2329. SetWindowLongPtr( hParent, DWLP_MSGRESULT, ( fAbort ? 0 : -1 ));
  2330. RETURN(!fAbort);
  2331. }