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.

1611 lines
47 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. hwwiz.c
  5. Abstract:
  6. Implements a upgwiz wizard for obtaining various application information.
  7. Author:
  8. Calin Negreanu (calinn) 10-Oct-1998
  9. Revision History:
  10. <alias> <date> <comments>
  11. --*/
  12. #include "pch.h"
  13. #include "..\inc\dgdll.h"
  14. #include <cpl.h>
  15. DATATYPE g_DataTypes[] = {
  16. {UPGWIZ_VERSION,
  17. "Incompatible - requires app installation",
  18. "You must install the application that has incompatible modules, CPLs or SCRs).",
  19. 0,
  20. DTF_REQUIRE_DESCRIPTION|DTF_NO_DATA_OBJECT,
  21. 1024,
  22. "&Application name:"
  23. },
  24. {UPGWIZ_VERSION,
  25. "Compatible Application - requires app installation",
  26. "You specify the application that migrates fine on NT5.",
  27. 0,
  28. DTF_REQUIRE_DESCRIPTION|DTF_NO_DATA_OBJECT,
  29. 1024,
  30. "&Application name:"
  31. },
  32. {UPGWIZ_VERSION,
  33. "Incompatible Application",
  34. "You specify the application that is incompatible with Windows NT5.",
  35. 0,
  36. DTF_REQUIRE_DESCRIPTION,
  37. 1024,
  38. "&Application name:"
  39. },
  40. {UPGWIZ_VERSION,
  41. "Incompatible DOS Application",
  42. "You specify the DOS application that is incompatible with Windows NT5.",
  43. 0,
  44. DTF_REQUIRE_DESCRIPTION,
  45. 1024,
  46. "&Application name:"
  47. },
  48. {UPGWIZ_VERSION,
  49. "Application that needs to be reinstalled",
  50. "You specify an application that needs to be reinstalled after migration.",
  51. 0,
  52. DTF_REQUIRE_DESCRIPTION,
  53. 1024,
  54. "&Application name:"
  55. },
  56. {UPGWIZ_VERSION,
  57. "Application with minor problems",
  58. "You specify an application that has minor problems running on NT5.",
  59. 0,
  60. DTF_REQUIRE_DESCRIPTION|DTF_REQUIRE_TEXT,
  61. 1024,
  62. "&Application name:",
  63. "&Problem Description:"
  64. },
  65. {UPGWIZ_VERSION,
  66. "DOS Application with minor problems",
  67. "You specify an DOS application that has minor problems running on NT5.",
  68. 0,
  69. DTF_REQUIRE_DESCRIPTION|DTF_REQUIRE_TEXT,
  70. 1024,
  71. "&Application name:",
  72. "&Problem Description:"
  73. },
  74. {UPGWIZ_VERSION,
  75. "Incompatible CPLs",
  76. "You specify Control Panel Applets that are incompatible with NT5.",
  77. 0,
  78. DTF_REQUIRE_DESCRIPTION|DTF_ONE_SELECTION,
  79. 1024,
  80. "&CPL name:"
  81. },
  82. {UPGWIZ_VERSION,
  83. "CPLs with minor problems",
  84. "You specify Control Panel Applets that have minor problems running on NT5.",
  85. 0,
  86. DTF_REQUIRE_DESCRIPTION|DTF_REQUIRE_TEXT|DTF_ONE_SELECTION,
  87. 1024,
  88. "&CPL name:"
  89. },
  90. {UPGWIZ_VERSION,
  91. "Incompatible screen savers",
  92. "You specify screen savers that are incompatible with NT5.",
  93. 0,
  94. },
  95. {UPGWIZ_VERSION,
  96. "Screen savers with minor problems",
  97. "You specify screen savers that have minor problems while running on NT5.",
  98. 0,
  99. DTF_REQUIRE_TEXT|DTF_ONE_SELECTION,
  100. 1024,
  101. NULL,
  102. "&Problem description:"
  103. },
  104. {UPGWIZ_VERSION,
  105. "Compatible RunKey entries",
  106. "You specify RunKey entries that can be left after migration.",
  107. 0,
  108. },
  109. };
  110. GROWBUFFER g_DataObjects = GROWBUF_INIT;
  111. POOLHANDLE g_DataObjectPool;
  112. HINSTANCE g_OurInst;
  113. BOOL
  114. Init (
  115. VOID
  116. )
  117. {
  118. #ifndef UPGWIZ4FLOPPY
  119. return InitToolMode (g_OurInst);
  120. #else
  121. return TRUE;
  122. #endif
  123. }
  124. VOID
  125. Terminate (
  126. VOID
  127. )
  128. {
  129. //
  130. // Local cleanup
  131. //
  132. FreeGrowBuffer (&g_DataObjects);
  133. if (g_DataObjectPool) {
  134. PoolMemDestroyPool (g_DataObjectPool);
  135. }
  136. #ifndef UPGWIZ4FLOPPY
  137. TerminateToolMode (g_OurInst);
  138. #endif
  139. }
  140. BOOL
  141. WINAPI
  142. DllMain (
  143. IN HINSTANCE hInstance,
  144. IN DWORD dwReason,
  145. IN LPVOID lpReserved
  146. )
  147. {
  148. if (dwReason == DLL_PROCESS_DETACH) {
  149. MYASSERT (g_OurInst == hInstance);
  150. Terminate();
  151. }
  152. g_OurInst = hInstance;
  153. return TRUE;
  154. }
  155. UINT
  156. GiveVersion (
  157. VOID
  158. )
  159. {
  160. Init();
  161. return UPGWIZ_VERSION;
  162. }
  163. PDATATYPE
  164. GiveDataTypeList (
  165. OUT PUINT Count
  166. )
  167. {
  168. UINT u;
  169. *Count = sizeof (g_DataTypes) / sizeof (g_DataTypes[0]);
  170. for (u = 0 ; u < *Count ; u++) {
  171. g_DataTypes[u].DataTypeId = u;
  172. }
  173. return g_DataTypes;
  174. }
  175. VOID
  176. pGatherScreenSavers (
  177. VOID
  178. )
  179. {
  180. CHAR winDir [MAX_PATH];
  181. PCSTR scrDir = NULL;
  182. TREE_ENUM e;
  183. PDATAOBJECT Data;
  184. if (GetWindowsDirectory (winDir, MAX_PATH) == 0) {
  185. return;
  186. }
  187. if (ISNT()) {
  188. scrDir = JoinPaths (winDir, "SYSTEM32");
  189. }
  190. else {
  191. scrDir = JoinPaths (winDir, "SYSTEM");
  192. }
  193. if (EnumFirstFileInTreeEx (&e, scrDir, "*.scr", FALSE, FALSE, FILE_ENUM_THIS_LEVEL)) {
  194. do {
  195. if (!e.Directory) {
  196. Data = (PDATAOBJECT) GrowBuffer (&g_DataObjects, sizeof (DATAOBJECT));
  197. Data->NameOrPath = PoolMemDuplicateString (g_DataObjectPool, e.Name);
  198. Data->Version = UPGWIZ_VERSION;
  199. Data->Flags = 0;
  200. Data->DllParam = PoolMemDuplicateString (g_DataObjectPool, e.FullPath);
  201. }
  202. }
  203. while (EnumNextFileInTree (&e));
  204. }
  205. FreePathString (scrDir);
  206. }
  207. typedef struct _CPL_STRUCT {
  208. PSTR FriendlyName;
  209. PSTR FullPathName;
  210. } CPL_STRUCT, *PCPL_STRUCT;
  211. PCPL_STRUCT
  212. pAllocCPLStruct (
  213. IN PCSTR FriendlyName,
  214. IN PCSTR FullPathName
  215. )
  216. {
  217. PCPL_STRUCT cplStruct;
  218. cplStruct = (PCPL_STRUCT) PoolMemGetMemory (g_DataObjectPool, sizeof (CPL_STRUCT));
  219. ZeroMemory (cplStruct, sizeof (CPL_STRUCT));
  220. if (FriendlyName) {
  221. cplStruct->FriendlyName = PoolMemDuplicateString (g_DataObjectPool, FriendlyName);
  222. }
  223. if (FullPathName) {
  224. cplStruct->FullPathName = PoolMemDuplicateString (g_DataObjectPool, FullPathName);
  225. }
  226. return cplStruct;
  227. }
  228. typedef LONG (CPL_PROTOTYPE) (HWND hwndCPl, UINT uMsg, LONG lParam1, LONG lParam2);
  229. typedef CPL_PROTOTYPE * PCPL_PROTOTYPE;
  230. VOID
  231. pGetCPLFriendlyName (
  232. IN PCSTR FileName
  233. )
  234. {
  235. HANDLE cplInstance;
  236. PCPL_PROTOTYPE cplMain;
  237. TCHAR localName[MEMDB_MAX];
  238. UINT oldErrorMode;
  239. BOOL gathered;
  240. PDATAOBJECT Data;
  241. LONG numEntries,i;
  242. PCSTR uName;
  243. PCSTR displayName;
  244. LPCPLINFO info;
  245. LPNEWCPLINFO newInfo;
  246. oldErrorMode = SetErrorMode (SEM_FAILCRITICALERRORS);
  247. cplInstance = LoadLibrary (FileName);
  248. if (!cplInstance) {
  249. LOG ((LOG_ERROR, "Cannot load %s. Error:%ld", FileName, GetLastError()));
  250. Data = (PDATAOBJECT) GrowBuffer (&g_DataObjects, sizeof (DATAOBJECT));
  251. Data->NameOrPath = PoolMemDuplicateString (g_DataObjectPool, GetFileNameFromPath (FileName));
  252. Data->Version = UPGWIZ_VERSION;
  253. Data->Flags = 0;
  254. Data->DllParam = pAllocCPLStruct (NULL, FileName);
  255. SetErrorMode (oldErrorMode);
  256. return;
  257. }
  258. cplMain = (PCPL_PROTOTYPE)GetProcAddress (cplInstance, TEXT("CPlApplet"));
  259. if (!cplMain) {
  260. LOG ((LOG_ERROR, "Cannot get main entry point for %s. Error:%ld", FileName, GetLastError()));
  261. Data = (PDATAOBJECT) GrowBuffer (&g_DataObjects, sizeof (DATAOBJECT));
  262. Data->NameOrPath = PoolMemDuplicateString (g_DataObjectPool, GetFileNameFromPath (FileName));
  263. Data->Version = UPGWIZ_VERSION;
  264. Data->Flags = 0;
  265. Data->DllParam = pAllocCPLStruct (NULL, FileName);
  266. SetErrorMode (oldErrorMode);
  267. return;
  268. }
  269. if ((*cplMain) (NULL, CPL_INIT, 0, 0) == 0) {
  270. (*cplMain) (NULL, CPL_EXIT, 0, 0);
  271. LOG ((LOG_ERROR, "%s failed unexpectedly. Error:%ld", FileName, GetLastError()));
  272. Data = (PDATAOBJECT) GrowBuffer (&g_DataObjects, sizeof (DATAOBJECT));
  273. Data->NameOrPath = PoolMemDuplicateString (g_DataObjectPool, GetFileNameFromPath (FileName));
  274. Data->Version = UPGWIZ_VERSION;
  275. Data->Flags = 0;
  276. Data->DllParam = pAllocCPLStruct (NULL, FileName);
  277. FreeLibrary (cplInstance);
  278. SetErrorMode (oldErrorMode);
  279. return;
  280. }
  281. numEntries = (*cplMain) (NULL, CPL_GETCOUNT, 0, 0);
  282. if (numEntries == 0) {
  283. (*cplMain) (NULL, CPL_EXIT, 0, 0);
  284. Data = (PDATAOBJECT) GrowBuffer (&g_DataObjects, sizeof (DATAOBJECT));
  285. Data->NameOrPath = PoolMemDuplicateString (g_DataObjectPool, GetFileNameFromPath (FileName));
  286. Data->Version = UPGWIZ_VERSION;
  287. Data->Flags = 0;
  288. Data->DllParam = pAllocCPLStruct (NULL, FileName);
  289. FreeLibrary (cplInstance);
  290. SetErrorMode (oldErrorMode);
  291. DEBUGMSG ((DBG_WARNING, "CPL: No display info available for %s.", FileName));
  292. return;
  293. }
  294. info = MemAlloc (g_hHeap, HEAP_ZERO_MEMORY, sizeof (CPLINFO) * numEntries);
  295. newInfo = MemAlloc (g_hHeap, HEAP_ZERO_MEMORY, sizeof (NEWCPLINFO) * numEntries);
  296. gathered = FALSE;
  297. for (i=0;i<numEntries;i++) {
  298. (*cplMain) (NULL, CPL_INQUIRE, i, (LONG)&info[i]);
  299. (*cplMain) (NULL, CPL_NEWINQUIRE, i, (LONG)&newInfo[i]);
  300. if (newInfo[i].szName[0]) {
  301. uName = NULL;
  302. if (newInfo[i].szName[1]==0) {
  303. // let's try the unicode name
  304. uName = ConvertWtoA ((PWSTR)newInfo[i].szName);
  305. }
  306. displayName = JoinTextEx (NULL, uName?uName:newInfo[i].szName, GetFileNameFromPath (FileName), " - ", 0, NULL);
  307. Data = (PDATAOBJECT) GrowBuffer (&g_DataObjects, sizeof (DATAOBJECT));
  308. Data->NameOrPath = PoolMemDuplicateString (g_DataObjectPool, displayName);
  309. Data->Version = UPGWIZ_VERSION;
  310. Data->Flags = 0;
  311. Data->DllParam = pAllocCPLStruct (uName?uName:newInfo[i].szName, FileName);
  312. FreeText (displayName);
  313. if (uName) {
  314. FreeConvertedStr (uName);
  315. }
  316. gathered = TRUE;
  317. } else if (LoadString (cplInstance, info[i].idName, localName, MEMDB_MAX)) {
  318. displayName = JoinTextEx (NULL, localName, GetFileNameFromPath (FileName), " - ", 0, NULL);
  319. Data = (PDATAOBJECT) GrowBuffer (&g_DataObjects, sizeof (DATAOBJECT));
  320. Data->NameOrPath = PoolMemDuplicateString (g_DataObjectPool, displayName);
  321. Data->Version = UPGWIZ_VERSION;
  322. Data->Flags = 0;
  323. Data->DllParam = pAllocCPLStruct (localName, FileName);
  324. FreeText (displayName);
  325. gathered = TRUE;
  326. }
  327. ELSE_DEBUGMSG ((DBG_ERROR, "CPL: Can't get string id %u", info[i].idName));
  328. }
  329. for (i=0;i<numEntries;i++) {
  330. (*cplMain) (NULL, CPL_STOP, i, info[i].lData?info[i].lData:newInfo[i].lData);
  331. }
  332. if (!gathered) {
  333. Data = (PDATAOBJECT) GrowBuffer (&g_DataObjects, sizeof (DATAOBJECT));
  334. Data->NameOrPath = PoolMemDuplicateString (g_DataObjectPool, GetFileNameFromPath (FileName));
  335. Data->Version = UPGWIZ_VERSION;
  336. Data->Flags = 0;
  337. Data->DllParam = PoolMemDuplicateString (g_DataObjectPool, FileName);
  338. }
  339. (*cplMain) (NULL, CPL_EXIT, 0, 0);
  340. FreeLibrary (cplInstance);
  341. MemFree (g_hHeap, 0, newInfo);
  342. MemFree (g_hHeap, 0, info);
  343. SetErrorMode (oldErrorMode);
  344. return;
  345. }
  346. VOID
  347. pGatherCPLs (
  348. VOID
  349. )
  350. {
  351. CHAR winDir [MAX_PATH];
  352. PCSTR scrDir = NULL;
  353. TREE_ENUM e;
  354. if (GetWindowsDirectory (winDir, MAX_PATH) == 0) {
  355. return;
  356. }
  357. if (ISNT()) {
  358. scrDir = JoinPaths (winDir, "SYSTEM32");
  359. }
  360. else {
  361. scrDir = JoinPaths (winDir, "SYSTEM");
  362. }
  363. if (EnumFirstFileInTreeEx (&e, scrDir, "*.cpl", FALSE, FALSE, FILE_ENUM_THIS_LEVEL)) {
  364. do {
  365. if (!e.Directory) {
  366. pGetCPLFriendlyName (e.FullPath);
  367. }
  368. }
  369. while (EnumNextFileInTree (&e));
  370. }
  371. FreePathString (scrDir);
  372. }
  373. typedef struct _RUNKEY_STRUCT {
  374. PSTR ValueName;
  375. PSTR Value;
  376. } RUNKEY_STRUCT, *PRUNKEY_STRUCT;
  377. PRUNKEY_STRUCT
  378. pAllocRunKeyStruct (
  379. IN PCSTR ValueName,
  380. IN PCSTR Value
  381. )
  382. {
  383. PRUNKEY_STRUCT runKeyStruct;
  384. runKeyStruct = (PRUNKEY_STRUCT) PoolMemGetMemory (g_DataObjectPool, sizeof (RUNKEY_STRUCT));
  385. ZeroMemory (runKeyStruct, sizeof (RUNKEY_STRUCT));
  386. runKeyStruct->ValueName = PoolMemDuplicateString (g_DataObjectPool, ValueName);
  387. runKeyStruct->Value = PoolMemDuplicateString (g_DataObjectPool, Value);
  388. return runKeyStruct;
  389. }
  390. VOID
  391. pGatherRunKeys (
  392. VOID
  393. )
  394. {
  395. HKEY runKey;
  396. PCTSTR entryStr;
  397. REGVALUE_ENUM runKeyEnum;
  398. PDATAOBJECT Data;
  399. PCSTR displayName;
  400. runKey = OpenRegKeyStr (S_RUNKEY);
  401. if (runKey != NULL) {
  402. if (EnumFirstRegValue (&runKeyEnum, runKey)) {
  403. do {
  404. entryStr = GetRegValueString (runKey, runKeyEnum.ValueName);
  405. if (entryStr != NULL) {
  406. displayName = JoinTextEx (NULL, runKeyEnum.ValueName, entryStr, " - ", 0, NULL);
  407. Data = (PDATAOBJECT) GrowBuffer (&g_DataObjects, sizeof (DATAOBJECT));
  408. Data->NameOrPath = PoolMemDuplicateString (g_DataObjectPool, displayName);
  409. Data->Version = UPGWIZ_VERSION;
  410. Data->Flags = DOF_NO_SPLIT_ON_WACK;
  411. FreeText (displayName);
  412. Data->DllParam = pAllocRunKeyStruct (runKeyEnum.ValueName, entryStr);
  413. MemFree (g_hHeap, 0, entryStr);
  414. }
  415. }
  416. while (EnumNextRegValue (&runKeyEnum));
  417. }
  418. CloseRegKey (runKey);
  419. }
  420. runKey = OpenRegKeyStr (S_RUNKEY_USER);
  421. if (runKey != NULL) {
  422. if (EnumFirstRegValue (&runKeyEnum, runKey)) {
  423. do {
  424. entryStr = GetRegValueString (runKey, runKeyEnum.ValueName);
  425. if (entryStr != NULL) {
  426. displayName = JoinTextEx (NULL, runKeyEnum.ValueName, entryStr, " - ", 0, NULL);
  427. Data = (PDATAOBJECT) GrowBuffer (&g_DataObjects, sizeof (DATAOBJECT));
  428. Data->NameOrPath = PoolMemDuplicateString (g_DataObjectPool, displayName);
  429. Data->Version = UPGWIZ_VERSION;
  430. Data->Flags = 0;
  431. FreeText (displayName);
  432. Data->DllParam = pAllocRunKeyStruct (runKeyEnum.ValueName, entryStr);
  433. MemFree (g_hHeap, 0, entryStr);
  434. }
  435. }
  436. while (EnumNextRegValue (&runKeyEnum));
  437. }
  438. CloseRegKey (runKey);
  439. }
  440. }
  441. VOID
  442. pGatherStartMenuItems (
  443. HKEY Key,
  444. PCSTR ValueName,
  445. BOOL DosApps
  446. )
  447. {
  448. PCSTR entryStr;
  449. PCSTR expandedEntry;
  450. TREE_ENUM e;
  451. PDATAOBJECT Data;
  452. entryStr = GetRegValueString (Key, ValueName);
  453. if (entryStr) {
  454. expandedEntry = ExpandEnvironmentText (entryStr);
  455. if (EnumFirstFileInTreeEx (&e, expandedEntry, DosApps?"*.pif":"*.lnk", FALSE, FALSE, FILE_ENUM_ALL_LEVELS)) {
  456. do {
  457. if (!e.Directory) {
  458. Data = (PDATAOBJECT) GrowBuffer (&g_DataObjects, sizeof (DATAOBJECT));
  459. Data->NameOrPath = PoolMemDuplicateString (g_DataObjectPool, e.SubPath);
  460. Data->Version = UPGWIZ_VERSION;
  461. Data->Flags = 0;
  462. Data->DllParam = PoolMemDuplicateString (g_DataObjectPool, e.FullPath);
  463. }
  464. }
  465. while (EnumNextFileInTree (&e));
  466. }
  467. if (expandedEntry != entryStr) {
  468. FreeText (expandedEntry);
  469. }
  470. MemFree (g_hHeap, 0, entryStr);
  471. }
  472. }
  473. VOID
  474. pGatherStartMenu (
  475. BOOL DosApps
  476. )
  477. {
  478. HKEY startMenuKey;
  479. startMenuKey = OpenRegKeyStr ("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders");
  480. if (startMenuKey) {
  481. pGatherStartMenuItems (startMenuKey, "Common Start Menu", DosApps);
  482. pGatherStartMenuItems (startMenuKey, "Common Desktop", DosApps);
  483. CloseRegKey (startMenuKey);
  484. }
  485. startMenuKey = OpenRegKeyStr ("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders");
  486. if (startMenuKey) {
  487. pGatherStartMenuItems (startMenuKey, "Start Menu", DosApps);
  488. pGatherStartMenuItems (startMenuKey, "Desktop", DosApps);
  489. CloseRegKey (startMenuKey);
  490. }
  491. startMenuKey = OpenRegKeyStr ("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders");
  492. if (startMenuKey) {
  493. pGatherStartMenuItems (startMenuKey, "Common Start Menu", DosApps);
  494. pGatherStartMenuItems (startMenuKey, "Common Desktop", DosApps);
  495. CloseRegKey (startMenuKey);
  496. }
  497. startMenuKey = OpenRegKeyStr ("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders");
  498. if (startMenuKey) {
  499. pGatherStartMenuItems (startMenuKey, "Start Menu", DosApps);
  500. pGatherStartMenuItems (startMenuKey, "Desktop", DosApps);
  501. CloseRegKey (startMenuKey);
  502. }
  503. }
  504. PDATAOBJECT
  505. GiveDataObjectList (
  506. IN UINT DataTypeId,
  507. OUT PUINT Count
  508. )
  509. {
  510. g_DataObjectPool = PoolMemInitNamedPool ("Data Objects");
  511. switch (DataTypeId) {
  512. case 0:
  513. // compatible Apps
  514. MessageBox (NULL, "Internal App DLL error:00004. Please contact calinn.", "Error", MB_OK);
  515. break;
  516. case 1:
  517. // compatible Apps
  518. MessageBox (NULL, "Internal App DLL error:00002. Please contact calinn.", "Error", MB_OK);
  519. break;
  520. case 2:
  521. // incompatible Apps
  522. pGatherStartMenu (FALSE);
  523. break;
  524. case 3:
  525. // incompatible DOS Apps
  526. pGatherStartMenu (TRUE);
  527. break;
  528. case 4:
  529. // Apps to be reinstalled
  530. pGatherStartMenu (FALSE);
  531. break;
  532. case 5:
  533. // Apps with minor problems
  534. pGatherStartMenu (FALSE);
  535. break;
  536. case 6:
  537. // DOS Apps with minor problems
  538. pGatherStartMenu (TRUE);
  539. break;
  540. case 7:
  541. // incompatible CPLs
  542. pGatherCPLs ();
  543. break;
  544. case 8:
  545. // CPLs with minor problems
  546. pGatherCPLs ();
  547. break;
  548. case 9:
  549. // incompatible SCRs
  550. pGatherScreenSavers ();
  551. break;
  552. case 10:
  553. // SCRs with minor problems
  554. pGatherScreenSavers ();
  555. break;
  556. case 11:
  557. // compatible RunKey entries
  558. pGatherRunKeys ();
  559. break;
  560. default:
  561. MessageBox (NULL, "Internal App DLL error:00001. Please contact calinn.", "Error", MB_OK);
  562. break;
  563. }
  564. *Count = g_DataObjects.End / sizeof (DATAOBJECT);
  565. return (PDATAOBJECT) g_DataObjects.Buf;
  566. }
  567. BOOL
  568. pIncompatibleSCROutput (
  569. IN HANDLE File
  570. )
  571. {
  572. BOOL b = FALSE;
  573. CHAR dataStr[MAX_PATH];
  574. PDATAOBJECT Data = (PDATAOBJECT) g_DataObjects.Buf;
  575. if (!WizardWriteRealString (File, "[Screen Savers - Incompatible]\r\n")) {
  576. return FALSE;
  577. }
  578. while ((DWORD)Data < (DWORD)g_DataObjects.Buf + g_DataObjects.End) {
  579. if (Data->Flags & DOF_SELECTED) {
  580. if (GetFileAttributesLine ((PSTR)Data->DllParam, dataStr, MAX_PATH)) {
  581. b = WizardWriteString (File, dataStr);
  582. b = b && WizardWriteRealString (File, "\r\n");
  583. if (!b) break;
  584. }
  585. }
  586. Data++;
  587. }
  588. b = b && WizardWriteRealString (File, "\r\n");
  589. return b;
  590. }
  591. BOOL
  592. pMinorProblemsSCROutput (
  593. IN HANDLE File,
  594. IN POUTPUTARGS Args
  595. )
  596. {
  597. BOOL b = FALSE;
  598. CHAR dataStr[MAX_PATH];
  599. PDATAOBJECT Data = (PDATAOBJECT) g_DataObjects.Buf;
  600. if (!WizardWriteRealString (File, "[MinorProblems]\r\n")) {
  601. return FALSE;
  602. }
  603. while ((DWORD)Data < (DWORD)g_DataObjects.Buf + g_DataObjects.End) {
  604. if (Data->Flags & DOF_SELECTED) {
  605. MYASSERT (GetFileExtensionFromPath ((PSTR)Data->DllParam));
  606. StringCopyAB (dataStr, GetFileNameFromPath ((PSTR)Data->DllParam), _mbsdec(GetFileNameFromPath ((PSTR)Data->DllParam), GetFileExtensionFromPath ((PSTR)Data->DllParam)));
  607. b = WizardWriteColumn (File, dataStr, 30);
  608. b = b && WizardWriteRealString (File, ", %");
  609. b = b && WizardWriteInfString (File, dataStr, FALSE, FALSE, TRUE, '_', 0);
  610. b = b && WizardWriteRealString (File, "%, ");
  611. b = b && GetFileAttributesLine ((PSTR)Data->DllParam, dataStr, MAX_PATH);
  612. b = b && WizardWriteString (File, dataStr);
  613. b = b && WizardWriteString (File, "\r\n");
  614. b = b && WizardWriteString (File, "[Strings]\r\n");
  615. StringCopyAB (dataStr, GetFileNameFromPath ((PSTR)Data->DllParam), _mbsdec(GetFileNameFromPath ((PSTR)Data->DllParam), GetFileExtensionFromPath ((PSTR)Data->DllParam)));
  616. b = b && WizardWriteInfString (File, dataStr, FALSE, FALSE, TRUE, '_', 0);
  617. b = b && WizardWriteColumn (File, "=", 1);
  618. b = b && WizardWriteInfString (File, Args->OptionalText, TRUE, TRUE, FALSE, 0, 0);
  619. b = b && WizardWriteRealString (File, "\r\n");
  620. if (!b) break;
  621. }
  622. Data++;
  623. }
  624. b = b && WizardWriteRealString (File, "\r\n");
  625. return b;
  626. }
  627. BOOL
  628. pIncompatibleCPLOutput (
  629. IN HANDLE File,
  630. IN POUTPUTARGS Args
  631. )
  632. {
  633. BOOL b = FALSE;
  634. CHAR dataStr[MAX_PATH];
  635. PDATAOBJECT Data = (PDATAOBJECT) g_DataObjects.Buf;
  636. PCPL_STRUCT cplStruct;
  637. if (!WizardWriteRealString (File, "[ControlPanelApplets]\r\n")) {
  638. return FALSE;
  639. }
  640. while ((DWORD)Data < (DWORD)g_DataObjects.Buf + g_DataObjects.End) {
  641. if (Data->Flags & DOF_SELECTED) {
  642. cplStruct = (PCPL_STRUCT)Data->DllParam;
  643. if (GetFileAttributesLine ((PSTR)cplStruct->FullPathName, dataStr, MAX_PATH)) {
  644. b = WizardWriteQuotedColumn (File, cplStruct->FriendlyName?cplStruct->FriendlyName:Args->OptionalDescription, 30);
  645. b = b && WizardWriteRealString (File, ",, ");
  646. b = b && WizardWriteString (File, dataStr);
  647. b = b && WizardWriteRealString (File, "\r\n");
  648. if (!b) break;
  649. }
  650. }
  651. Data++;
  652. }
  653. b = b && WizardWriteRealString (File, "\r\n");
  654. return b;
  655. }
  656. BOOL
  657. pMinorCPLOutput (
  658. IN HANDLE File,
  659. IN POUTPUTARGS Args
  660. )
  661. {
  662. BOOL b = FALSE;
  663. CHAR dataStr[MAX_PATH];
  664. PDATAOBJECT Data = (PDATAOBJECT) g_DataObjects.Buf;
  665. PCPL_STRUCT cplStruct = NULL;
  666. if (!WizardWriteRealString (File, "[ControlPanelApplets]\r\n")) {
  667. return FALSE;
  668. }
  669. while ((DWORD)Data < (DWORD)g_DataObjects.Buf + g_DataObjects.End) {
  670. if (Data->Flags & DOF_SELECTED) {
  671. cplStruct = (PCPL_STRUCT)Data->DllParam;
  672. if (GetFileAttributesLine ((PSTR)cplStruct->FullPathName, dataStr, MAX_PATH)) {
  673. b = WizardWriteQuotedColumn (File, cplStruct->FriendlyName?cplStruct->FriendlyName:Args->OptionalDescription, 30);
  674. b = b && WizardWriteRealString (File, ", %");
  675. b = b && WizardWriteInfString (File, cplStruct->FriendlyName?cplStruct->FriendlyName:Args->OptionalDescription, FALSE, FALSE, TRUE, '_', 0);
  676. b = b && WizardWriteRealString (File, "%, ");
  677. b = b && WizardWriteString (File, dataStr);
  678. b = b && WizardWriteRealString (File, "\r\n");
  679. if (!b) break;
  680. }
  681. }
  682. Data++;
  683. }
  684. b = b && WizardWriteRealString (File, "\r\n");
  685. b = b && WizardWriteRealString (File, "[Strings]\r\n");
  686. b = b && WizardWriteInfString (File, cplStruct->FriendlyName?cplStruct->FriendlyName:Args->OptionalDescription, FALSE, FALSE, TRUE, '_', 0);
  687. b = b && WizardWriteRealString (File, "=");
  688. b = b && WizardWriteInfString (File, Args->OptionalText, TRUE, TRUE, FALSE, 0, 0);
  689. b = b && WizardWriteRealString (File, "\r\n");
  690. return b;
  691. }
  692. PCTSTR
  693. pSearchModule (
  694. IN PCTSTR CommandLine
  695. )
  696. {
  697. PTSTR nextChar;
  698. TCHAR module [MAX_TCHAR_PATH] = TEXT("");
  699. TCHAR moduleLong [MAX_TCHAR_PATH] = TEXT("");
  700. PATH_ENUM pathEnum;
  701. PTSTR candidate;
  702. ExtractArgZero (CommandLine, module);
  703. nextChar = _tcsinc (module);
  704. if ((nextChar != NULL) &&
  705. (_tcsnextc (nextChar) == ':')
  706. ){
  707. if (!OurGetLongPathName (module, moduleLong, MAX_TCHAR_PATH)) {
  708. _tcsncpy (moduleLong, module, MAX_TCHAR_PATH);
  709. }
  710. return DuplicatePathString (moduleLong, 0);
  711. }
  712. else {
  713. if (EnumFirstPath (&pathEnum, NULL, g_WinDir, g_SystemDir)) {
  714. do {
  715. candidate = JoinPaths (pathEnum.PtrCurrPath, module);
  716. if (DoesFileExist (candidate)) {
  717. return candidate;
  718. }
  719. FreePathString (candidate);
  720. }
  721. while (EnumNextPath (&pathEnum));
  722. }
  723. EnumPathAbort (&pathEnum);
  724. }
  725. return NULL;
  726. }
  727. BOOL
  728. pCompatibleRunKeyOutput (
  729. IN HANDLE File
  730. )
  731. {
  732. BOOL b = FALSE;
  733. CHAR dataStr[MAX_PATH];
  734. PDATAOBJECT Data = (PDATAOBJECT) g_DataObjects.Buf;
  735. PRUNKEY_STRUCT runKeyStruct;
  736. PCSTR fullFileName;
  737. if (!WizardWriteRealString (File, "[CompatibleRunKeyModules]\r\n")) {
  738. return FALSE;
  739. }
  740. while ((DWORD)Data < (DWORD)g_DataObjects.Buf + g_DataObjects.End) {
  741. if (Data->Flags & DOF_SELECTED) {
  742. runKeyStruct = (PRUNKEY_STRUCT)Data->DllParam;
  743. fullFileName = pSearchModule (runKeyStruct->Value);
  744. if (fullFileName) {
  745. if (GetFileAttributesLine ((PSTR)fullFileName, dataStr, MAX_PATH)) {
  746. b = WizardWriteQuotedColumn (File, runKeyStruct->ValueName, 30);
  747. b = b && WizardWriteRealString (File, ",, ");
  748. b = b && WizardWriteString (File, dataStr);
  749. b = b && WizardWriteRealString (File, "\r\n");
  750. if (!b) break;
  751. }
  752. }
  753. }
  754. Data++;
  755. }
  756. b = b && WizardWriteRealString (File, "\r\n");
  757. return b;
  758. }
  759. BOOL
  760. pIncompatibleAppOutput (
  761. IN HANDLE File,
  762. IN POUTPUTARGS Args,
  763. IN BOOL DosApp
  764. )
  765. {
  766. BOOL b = TRUE;
  767. CHAR dataStr[MAX_PATH];
  768. PDATAOBJECT Data = (PDATAOBJECT) g_DataObjects.Buf;
  769. IShellLink *ShellLink;
  770. IPersistFile *PersistFile;
  771. CHAR sTarget [MAX_PATH];
  772. CHAR sParams [MAX_PATH];
  773. CHAR sWorkDir [MAX_PATH];
  774. CHAR sIconPath [MAX_PATH];
  775. INT sIconNr;
  776. WORD sHotKey;
  777. BOOL sDosApp;
  778. BOOL sMsDosMode;
  779. DWORD fileCount = 0;
  780. PCSTR fileName=NULL;
  781. if (!InitCOMLink (&ShellLink, &PersistFile)) {
  782. return FALSE;
  783. }
  784. fileCount = 0;
  785. fileName = NULL;
  786. while ((DWORD)Data < (DWORD)g_DataObjects.Buf + g_DataObjects.End) {
  787. if (Data->Flags & DOF_SELECTED) {
  788. b = b && ExtractShortcutInfo (
  789. sTarget,
  790. sParams,
  791. sWorkDir,
  792. sIconPath,
  793. &sIconNr,
  794. &sHotKey,
  795. &sDosApp,
  796. &sMsDosMode,
  797. NULL,
  798. NULL,
  799. (PSTR)Data->DllParam,
  800. ShellLink,
  801. PersistFile);
  802. if (!b) {
  803. break;
  804. }
  805. fileCount ++;
  806. switch (fileCount) {
  807. case 1: fileName = DuplicatePathString (sTarget, 0);
  808. b = b && WizardWriteRealString (File, DosApp?"[DosApps]\r\n":"[Incompatible]\r\n");
  809. break;
  810. case 2: b = b && WizardWriteRealString (File, Args->OptionalDescription);
  811. b = b && WizardWriteRealString (File, "\r\n\r\n");
  812. b = b && WizardWriteRealString (File, "[");
  813. b = b && WizardWriteRealString (File, Args->OptionalDescription);
  814. b = b && WizardWriteRealString (File, "]\r\n");
  815. b = b && GetFileAttributesLine (fileName, dataStr, MAX_PATH);
  816. b = b && WizardWriteRealString (File, dataStr);
  817. b = b && WizardWriteRealString (File, "\r\n");
  818. default:b = b && GetFileAttributesLine (sTarget, dataStr, MAX_PATH);
  819. b = b && WizardWriteRealString (File, dataStr);
  820. b = b && WizardWriteRealString (File, "\r\n");
  821. }
  822. }
  823. Data++;
  824. }
  825. if (fileCount == 1) {
  826. b = b && WizardWriteRealString (File, Args->OptionalDescription);
  827. b = b && WizardWriteRealString (File, ",, ");
  828. b = b && GetFileAttributesLine (fileName, dataStr, MAX_PATH);
  829. b = b && WizardWriteRealString (File, dataStr);
  830. b = b && WizardWriteRealString (File, "\r\n");
  831. }
  832. if (fileCount) {
  833. b = b && WizardWriteRealString (File, "\r\n");
  834. }
  835. FreeCOMLink (&ShellLink, &PersistFile);
  836. return b;
  837. }
  838. BOOL
  839. pReinstallAppOutput (
  840. IN HANDLE File,
  841. IN POUTPUTARGS Args
  842. )
  843. {
  844. BOOL b = TRUE;
  845. CHAR dataStr[MAX_PATH];
  846. PDATAOBJECT Data = (PDATAOBJECT) g_DataObjects.Buf;
  847. IShellLink *ShellLink;
  848. IPersistFile *PersistFile;
  849. CHAR sTarget [MAX_PATH];
  850. CHAR sParams [MAX_PATH];
  851. CHAR sWorkDir [MAX_PATH];
  852. CHAR sIconPath [MAX_PATH];
  853. INT sIconNr;
  854. WORD sHotKey;
  855. BOOL sDosApp;
  856. BOOL sMsDosMode;
  857. DWORD fileCount = 0;
  858. PCSTR fileName=NULL;
  859. if (!InitCOMLink (&ShellLink, &PersistFile)) {
  860. return FALSE;
  861. }
  862. fileCount = 0;
  863. fileName = NULL;
  864. while ((DWORD)Data < (DWORD)g_DataObjects.Buf + g_DataObjects.End) {
  865. if (Data->Flags & DOF_SELECTED) {
  866. b = b && ExtractShortcutInfo (
  867. sTarget,
  868. sParams,
  869. sWorkDir,
  870. sIconPath,
  871. &sIconNr,
  872. &sHotKey,
  873. &sDosApp,
  874. &sMsDosMode,
  875. NULL,
  876. NULL,
  877. (PSTR)Data->DllParam,
  878. ShellLink,
  879. PersistFile);
  880. if (!b) {
  881. break;
  882. }
  883. fileCount ++;
  884. switch (fileCount) {
  885. case 1: fileName = DuplicatePathString (sTarget, 0);
  886. b = b && WizardWriteRealString (File, "[Reinstall]\r\n");
  887. break;
  888. case 2: b = b && WizardWriteRealString (File, Args->OptionalDescription);
  889. b = b && WizardWriteRealString (File, "\r\n\r\n");
  890. b = b && WizardWriteRealString (File, "[");
  891. b = b && WizardWriteRealString (File, Args->OptionalDescription);
  892. b = b && WizardWriteRealString (File, "]\r\n");
  893. b = b && GetFileAttributesLine (fileName, dataStr, MAX_PATH);
  894. b = b && WizardWriteRealString (File, dataStr);
  895. b = b && WizardWriteRealString (File, "\r\n");
  896. default:b = b && GetFileAttributesLine (sTarget, dataStr, MAX_PATH);
  897. b = b && WizardWriteRealString (File, dataStr);
  898. b = b && WizardWriteRealString (File, "\r\n");
  899. }
  900. }
  901. Data++;
  902. }
  903. if (fileCount == 1) {
  904. b = b && WizardWriteRealString (File, Args->OptionalDescription);
  905. b = b && WizardWriteRealString (File, ",, ");
  906. b = b && GetFileAttributesLine (fileName, dataStr, MAX_PATH);
  907. b = b && WizardWriteRealString (File, dataStr);
  908. b = b && WizardWriteRealString (File, "\r\n");
  909. }
  910. if (fileCount) {
  911. b = b && WizardWriteRealString (File, "\r\n");
  912. }
  913. FreeCOMLink (&ShellLink, &PersistFile);
  914. return b;
  915. }
  916. BOOL
  917. pMinorProblemsAppOutput (
  918. IN HANDLE File,
  919. IN POUTPUTARGS Args,
  920. IN BOOL DosApp
  921. )
  922. {
  923. BOOL b = TRUE;
  924. CHAR dataStr[MAX_PATH];
  925. PDATAOBJECT Data = (PDATAOBJECT) g_DataObjects.Buf;
  926. IShellLink *ShellLink;
  927. IPersistFile *PersistFile;
  928. CHAR sTarget [MAX_PATH];
  929. CHAR sParams [MAX_PATH];
  930. CHAR sWorkDir [MAX_PATH];
  931. CHAR sIconPath [MAX_PATH];
  932. INT sIconNr;
  933. WORD sHotKey;
  934. BOOL sDosApp;
  935. BOOL sMsDosMode;
  936. DWORD fileCount = 0;
  937. PCSTR fileName=NULL;
  938. if (!InitCOMLink (&ShellLink, &PersistFile)) {
  939. return FALSE;
  940. }
  941. fileCount = 0;
  942. fileName = NULL;
  943. while ((DWORD)Data < (DWORD)g_DataObjects.Buf + g_DataObjects.End) {
  944. if (Data->Flags & DOF_SELECTED) {
  945. b = b && ExtractShortcutInfo (
  946. sTarget,
  947. sParams,
  948. sWorkDir,
  949. sIconPath,
  950. &sIconNr,
  951. &sHotKey,
  952. &sDosApp,
  953. &sMsDosMode,
  954. NULL,
  955. NULL,
  956. (PSTR)Data->DllParam,
  957. ShellLink,
  958. PersistFile);
  959. if (!b) {
  960. break;
  961. }
  962. fileCount ++;
  963. switch (fileCount) {
  964. case 1: fileName = DuplicatePathString (sTarget, 0);
  965. b = b && WizardWriteRealString (File, DosApp?"[DosApps]\r\n":"[MinorProblems]\r\n");
  966. break;
  967. case 2: b = b && WizardWriteRealString (File, Args->OptionalDescription);
  968. b = b && WizardWriteRealString (File, ", %");
  969. b = b && WizardWriteInfString (File, Args->OptionalDescription, FALSE, FALSE, TRUE, '_', 0);
  970. b = b && WizardWriteRealString (File, "%");
  971. b = b && WizardWriteRealString (File, "\r\n\r\n");
  972. b = b && WizardWriteRealString (File, "[");
  973. b = b && WizardWriteRealString (File, Args->OptionalDescription);
  974. b = b && WizardWriteRealString (File, "]\r\n");
  975. b = b && GetFileAttributesLine (fileName, dataStr, MAX_PATH);
  976. b = b && WizardWriteRealString (File, dataStr);
  977. b = b && WizardWriteRealString (File, "\r\n");
  978. default:b = b && GetFileAttributesLine (sTarget, dataStr, MAX_PATH);
  979. b = b && WizardWriteRealString (File, dataStr);
  980. b = b && WizardWriteRealString (File, "\r\n");
  981. }
  982. }
  983. Data++;
  984. }
  985. if (fileCount == 1) {
  986. b = b && WizardWriteRealString (File, Args->OptionalDescription);
  987. b = b && WizardWriteRealString (File, ", %");
  988. b = b && WizardWriteInfString (File, Args->OptionalDescription, FALSE, FALSE, TRUE, '_', 0);
  989. b = b && WizardWriteRealString (File, "%, ");
  990. b = b && GetFileAttributesLine (fileName, dataStr, MAX_PATH);
  991. b = b && WizardWriteRealString (File, dataStr);
  992. b = b && WizardWriteRealString (File, "\r\n");
  993. }
  994. if (fileCount) {
  995. b = b && WizardWriteRealString (File, "\r\n");
  996. b = b && WizardWriteRealString (File, "[Strings]\r\n");
  997. b = b && WizardWriteInfString (File, Args->OptionalDescription, FALSE, FALSE, TRUE, '_', 0);
  998. b = b && WizardWriteRealString (File, "=");
  999. b = b && WizardWriteInfString (File, Args->OptionalText, TRUE, TRUE, FALSE, 0, 0);
  1000. b = b && WizardWriteRealString (File, "\r\n");
  1001. }
  1002. FreeCOMLink (&ShellLink, &PersistFile);
  1003. return b;
  1004. }
  1005. BOOL
  1006. pCompatibleAppOutput (
  1007. IN HANDLE File,
  1008. IN POUTPUTARGS Args
  1009. )
  1010. {
  1011. BOOL b = TRUE;
  1012. CHAR dataStr[MAX_PATH];
  1013. PDATAOBJECT Data = (PDATAOBJECT) g_DataObjects.Buf;
  1014. SNAP_FILE_ENUMA e;
  1015. DWORD fileCount = 0;
  1016. PCSTR fileName=NULL;
  1017. fileCount = 0;
  1018. fileName = NULL;
  1019. if (EnumFirstSnapFile (&e, "*.EXE", SNAP_RESULT_CHANGED|SNAP_RESULT_ADDED)) {
  1020. do {
  1021. fileCount ++;
  1022. switch (fileCount) {
  1023. case 1: fileName = DuplicatePathString (e.FileName, 0);
  1024. b = b && WizardWriteRealString (File, "[CompatibleFiles]\r\n");
  1025. break;
  1026. case 2: b = b && WizardWriteRealString (File, Args->OptionalDescription);
  1027. b = b && WizardWriteRealString (File, "\r\n\r\n");
  1028. b = b && WizardWriteRealString (File, "[");
  1029. b = b && WizardWriteRealString (File, Args->OptionalDescription);
  1030. b = b && WizardWriteRealString (File, "]\r\n");
  1031. b = b && GetFileAttributesLine (fileName, dataStr, MAX_PATH);
  1032. b = b && WizardWriteRealString (File, dataStr);
  1033. b = b && WizardWriteRealString (File, "\r\n");
  1034. default:b = b && GetFileAttributesLine (e.FileName, dataStr, MAX_PATH);
  1035. b = b && WizardWriteRealString (File, dataStr);
  1036. b = b && WizardWriteRealString (File, "\r\n");
  1037. }
  1038. } while (EnumNextSnapFile (&e));
  1039. }
  1040. if (fileCount == 1) {
  1041. b = b && WizardWriteRealString (File, Args->OptionalDescription);
  1042. b = b && WizardWriteRealString (File, ",, ");
  1043. b = b && GetFileAttributesLine (fileName, dataStr, MAX_PATH);
  1044. b = b && WizardWriteRealString (File, dataStr);
  1045. b = b && WizardWriteRealString (File, "\r\n");
  1046. }
  1047. if (fileCount) {
  1048. b = b && WizardWriteRealString (File, "\r\n");
  1049. }
  1050. return b;
  1051. }
  1052. BOOL
  1053. pIncompatibleAllOutput (
  1054. IN HANDLE File,
  1055. IN POUTPUTARGS Args
  1056. )
  1057. {
  1058. BOOL b = TRUE;
  1059. CHAR dataStr[MAX_PATH];
  1060. PDATAOBJECT Data = (PDATAOBJECT) g_DataObjects.Buf;
  1061. SNAP_FILE_ENUMA e;
  1062. DWORD fileCount = 0;
  1063. PCSTR fileName=NULL;
  1064. fileCount = 0;
  1065. fileName = NULL;
  1066. if (EnumFirstSnapFile (&e, "*.EXE", SNAP_RESULT_CHANGED|SNAP_RESULT_ADDED)) {
  1067. do {
  1068. fileCount ++;
  1069. switch (fileCount) {
  1070. case 1: fileName = DuplicatePathString (e.FileName, 0);
  1071. b = b && WizardWriteRealString (File, "[Incompatible]\r\n");
  1072. break;
  1073. case 2: b = b && WizardWriteRealString (File, Args->OptionalDescription);
  1074. b = b && WizardWriteRealString (File, "\r\n\r\n");
  1075. b = b && WizardWriteRealString (File, "[");
  1076. b = b && WizardWriteRealString (File, Args->OptionalDescription);
  1077. b = b && WizardWriteRealString (File, "]\r\n");
  1078. b = b && GetFileAttributesLine (fileName, dataStr, MAX_PATH);
  1079. b = b && WizardWriteRealString (File, dataStr);
  1080. b = b && WizardWriteRealString (File, "\r\n");
  1081. default:b = b && GetFileAttributesLine (e.FileName, dataStr, MAX_PATH);
  1082. b = b && WizardWriteRealString (File, dataStr);
  1083. b = b && WizardWriteRealString (File, "\r\n");
  1084. }
  1085. } while (EnumNextSnapFile (&e));
  1086. }
  1087. if (EnumFirstSnapFile (&e, "*.SCR", SNAP_RESULT_CHANGED|SNAP_RESULT_ADDED)) {
  1088. do {
  1089. fileCount ++;
  1090. switch (fileCount) {
  1091. case 1: fileName = DuplicatePathString (e.FileName, 0);
  1092. b = b && WizardWriteRealString (File, "[Incompatible]\r\n");
  1093. break;
  1094. case 2: b = b && WizardWriteRealString (File, Args->OptionalDescription);
  1095. b = b && WizardWriteRealString (File, "\r\n\r\n");
  1096. b = b && WizardWriteRealString (File, "[");
  1097. b = b && WizardWriteRealString (File, Args->OptionalDescription);
  1098. b = b && WizardWriteRealString (File, "]\r\n");
  1099. b = b && GetFileAttributesLine (fileName, dataStr, MAX_PATH);
  1100. b = b && WizardWriteRealString (File, dataStr);
  1101. b = b && WizardWriteRealString (File, "\r\n");
  1102. default:b = b && GetFileAttributesLine (e.FileName, dataStr, MAX_PATH);
  1103. b = b && WizardWriteRealString (File, dataStr);
  1104. b = b && WizardWriteRealString (File, "\r\n");
  1105. }
  1106. } while (EnumNextSnapFile (&e));
  1107. }
  1108. if (fileCount == 1) {
  1109. b = b && WizardWriteRealString (File, Args->OptionalDescription);
  1110. b = b && WizardWriteRealString (File, ",, ");
  1111. b = b && GetFileAttributesLine (fileName, dataStr, MAX_PATH);
  1112. b = b && WizardWriteRealString (File, dataStr);
  1113. b = b && WizardWriteRealString (File, "\r\n");
  1114. }
  1115. if (fileCount) {
  1116. b = b && WizardWriteRealString (File, "\r\n");
  1117. }
  1118. fileCount = 0;
  1119. fileName = NULL;
  1120. if (EnumFirstSnapFile (&e, "*.CPL", SNAP_RESULT_CHANGED|SNAP_RESULT_ADDED)) {
  1121. do {
  1122. fileCount ++;
  1123. switch (fileCount) {
  1124. case 1: fileName = DuplicatePathString (e.FileName, 0);
  1125. b = b && WizardWriteRealString (File, "[ControlPanelApplets]\r\n");
  1126. break;
  1127. case 2: b = b && WizardWriteRealString (File, Args->OptionalDescription);
  1128. b = b && WizardWriteRealString (File, "\r\n\r\n");
  1129. b = b && WizardWriteRealString (File, "[");
  1130. b = b && WizardWriteRealString (File, Args->OptionalDescription);
  1131. b = b && WizardWriteRealString (File, "-CPLs]\r\n");
  1132. b = b && GetFileAttributesLine (fileName, dataStr, MAX_PATH);
  1133. b = b && WizardWriteRealString (File, dataStr);
  1134. b = b && WizardWriteRealString (File, "\r\n");
  1135. default:b = b && GetFileAttributesLine (e.FileName, dataStr, MAX_PATH);
  1136. b = b && WizardWriteRealString (File, dataStr);
  1137. b = b && WizardWriteRealString (File, "\r\n");
  1138. }
  1139. } while (EnumNextSnapFile (&e));
  1140. }
  1141. if (fileCount == 1) {
  1142. b = b && WizardWriteRealString (File, Args->OptionalDescription);
  1143. b = b && WizardWriteRealString (File, "-CPLs,, ");
  1144. b = b && GetFileAttributesLine (fileName, dataStr, MAX_PATH);
  1145. b = b && WizardWriteRealString (File, dataStr);
  1146. b = b && WizardWriteRealString (File, "\r\n");
  1147. }
  1148. if (fileCount) {
  1149. b = b && WizardWriteRealString (File, "\r\n");
  1150. }
  1151. return b;
  1152. }
  1153. BOOL
  1154. GenerateOutput (
  1155. IN POUTPUTARGS Args
  1156. )
  1157. {
  1158. BOOL b = FALSE;
  1159. HANDLE File;
  1160. CHAR Path[MAX_MBCHAR_PATH];
  1161. switch (Args->DataTypeId) {
  1162. case 0:
  1163. // incompatible - snapshot
  1164. wsprintf (Path, "%s\\IncAll.txt", Args->OutboundDir);
  1165. break;
  1166. case 1:
  1167. // compatible Apps
  1168. wsprintf (Path, "%s\\CompatA.txt", Args->OutboundDir);
  1169. break;
  1170. case 2:
  1171. // incompatible Apps
  1172. wsprintf (Path, "%s\\IncompA.txt", Args->OutboundDir);
  1173. break;
  1174. case 3:
  1175. // incompatible DOS Apps
  1176. wsprintf (Path, "%s\\IncompDA.txt", Args->OutboundDir);
  1177. break;
  1178. case 4:
  1179. // Apps to be reinstalled
  1180. wsprintf (Path, "%s\\ReinstA.txt", Args->OutboundDir);
  1181. break;
  1182. case 5:
  1183. // Apps with minor problems
  1184. wsprintf (Path, "%s\\MinorA.txt", Args->OutboundDir);
  1185. break;
  1186. case 6:
  1187. // DOS Apps with minor problems
  1188. wsprintf (Path, "%s\\MinorDA.txt", Args->OutboundDir);
  1189. break;
  1190. case 7:
  1191. // incompatible CPLs
  1192. wsprintf (Path, "%s\\IncCPL.txt", Args->OutboundDir);
  1193. break;
  1194. case 8:
  1195. // incompatible CPLs
  1196. wsprintf (Path, "%s\\MinorCPL.txt", Args->OutboundDir);
  1197. break;
  1198. case 9:
  1199. // incompatible SCRs
  1200. wsprintf (Path, "%s\\IncSCR.txt", Args->OutboundDir);
  1201. break;
  1202. case 10:
  1203. // SCRs with minor problems
  1204. wsprintf (Path, "%s\\MinorSCR.txt", Args->OutboundDir);
  1205. break;
  1206. case 11:
  1207. // compatible RunKey entries
  1208. wsprintf (Path, "%s\\CompatRK.txt", Args->OutboundDir);
  1209. break;
  1210. default:
  1211. break;
  1212. }
  1213. printf ("Saving data to %s\n\n", Path);
  1214. File = CreateFile (
  1215. Path,
  1216. GENERIC_WRITE,
  1217. 0,
  1218. NULL,
  1219. OPEN_ALWAYS,
  1220. FILE_ATTRIBUTE_NORMAL,
  1221. NULL
  1222. );
  1223. if (File == INVALID_HANDLE_VALUE) {
  1224. printf ("Can't open file for output.\n");
  1225. return FALSE;
  1226. }
  1227. __try {
  1228. SetFilePointer (File, 0, NULL, FILE_END);
  1229. //
  1230. // Write [Identification] for all .inx files
  1231. //
  1232. if (!WizardWriteRealString (File, "[Identification]\r\n")) {
  1233. __leave;
  1234. }
  1235. //
  1236. // Write user name and date/time
  1237. //
  1238. if (!WriteHeader (File)) {
  1239. __leave;
  1240. }
  1241. switch (Args->DataTypeId) {
  1242. case 0:
  1243. // incompatible - snapshot
  1244. b = pIncompatibleAllOutput (File, Args);
  1245. break;
  1246. case 1:
  1247. // compatible Apps
  1248. b = pCompatibleAppOutput (File, Args);
  1249. break;
  1250. case 2:
  1251. // incompatible Apps
  1252. b = pIncompatibleAppOutput (File, Args, FALSE);
  1253. break;
  1254. case 3:
  1255. // incompatible DOS Apps
  1256. b = pIncompatibleAppOutput (File, Args, TRUE);
  1257. break;
  1258. case 4:
  1259. // Apps to be reinstalled
  1260. b = pReinstallAppOutput (File, Args);
  1261. break;
  1262. case 5:
  1263. // Apps with minor problems
  1264. b = pMinorProblemsAppOutput (File, Args, FALSE);
  1265. break;
  1266. case 6:
  1267. // DOS Apps with minor problems
  1268. b = pMinorProblemsAppOutput (File, Args, TRUE);
  1269. break;
  1270. case 7:
  1271. // incompatible CPLs
  1272. b = pIncompatibleCPLOutput (File, Args);
  1273. break;
  1274. case 8:
  1275. // CPLs with minor problems
  1276. b = pMinorCPLOutput (File, Args);
  1277. break;
  1278. case 9:
  1279. // incompatible SCRs
  1280. b = pIncompatibleSCROutput (File);
  1281. break;
  1282. case 10:
  1283. // SCRs with minor problems
  1284. b = pMinorProblemsSCROutput (File, Args);
  1285. break;
  1286. case 11:
  1287. // compatible RunKey entries
  1288. b = pCompatibleRunKeyOutput (File);
  1289. break;
  1290. default:
  1291. MessageBox (NULL, "Internal App DLL error:00003. Please contact calinn.", "Error", MB_OK);
  1292. }
  1293. //
  1294. // Write a final blank line
  1295. //
  1296. b = b && WizardWriteRealString (File, "\r\n");
  1297. }
  1298. __finally {
  1299. CloseHandle (File);
  1300. }
  1301. return b;
  1302. }
  1303. BOOL
  1304. DisplayOptionalUI (
  1305. IN POUTPUTARGS Args
  1306. )
  1307. {
  1308. PDATAOBJECT Data = (PDATAOBJECT) g_DataObjects.Buf;
  1309. PCPL_STRUCT cplStruct;
  1310. switch (Args->DataTypeId) {
  1311. case 0:
  1312. case 1:
  1313. printf ("Taking a snapshot of your system. Please wait...");
  1314. TakeSnapShotEx (SNAP_FILES);
  1315. printf ("Done\n");
  1316. MessageBox (NULL, "Please install your application and then press the OK button", "Install APP", MB_OK);
  1317. printf ("Generating a diff. Please wait...");
  1318. GenerateDiffOutputEx (NULL, NULL, FALSE, SNAP_FILES);
  1319. printf ("Done\n");
  1320. break;
  1321. case 7:
  1322. case 8:
  1323. // incompatible CPLs
  1324. while ((DWORD)Data < (DWORD)g_DataObjects.Buf + g_DataObjects.End) {
  1325. if (Data->Flags & DOF_SELECTED) {
  1326. cplStruct = (PCPL_STRUCT)Data->DllParam;
  1327. if (cplStruct->FriendlyName) {
  1328. g_DataTypes[Args->DataTypeId].Flags &= (~DTF_REQUIRE_DESCRIPTION);
  1329. }
  1330. }
  1331. Data ++;
  1332. }
  1333. break;
  1334. }
  1335. return TRUE;
  1336. }