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.

230 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. photosII.c
  5. Abstract:
  6. This source file implements the operations needed to properly migrate MGI PhotoSuite II 1.0 from
  7. Windows 9x to Windows NT. This is part of the Setup Migration DLL.
  8. Author:
  9. Calin Negreanu (calinn) 15-Jul-1999
  10. Revision History:
  11. --*/
  12. #include "pch.h"
  13. #define S_MIGRATION_PATHS "Migration Paths"
  14. #define S_PHOTOSII_FILE1 "PhotoSuite.EXE"
  15. #define S_PHOTOSII_FILE2 "W_Welcome.html"
  16. #define S_PHOTOSII_RELPATH1 "\\TempPSII\\Common\\"
  17. #define S_PHOTOSII_RELPATH2 "\\TempPSII\\Photos\\"
  18. #define MEMDB_CATEGORY_PHOTOSII "PhotoSuiteII"
  19. #define S_COMPANYNAME "CompanyName"
  20. #define S_PRODUCTVER "ProductVersion"
  21. #define S_PHOTOSII_COMPANYNAME "MGI Software*"
  22. #define S_PHOTOSII_PRODUCTVER "1.0*"
  23. static GROWBUFFER g_FilesBuff = GROWBUF_INIT;
  24. BOOL
  25. PhotoSuiteII_Attach (
  26. IN HINSTANCE DllInstance
  27. )
  28. {
  29. return TRUE;
  30. }
  31. BOOL
  32. PhotoSuiteII_Detach (
  33. IN HINSTANCE DllInstance
  34. )
  35. {
  36. FreeGrowBuffer (&g_FilesBuff);
  37. return TRUE;
  38. }
  39. LONG
  40. PhotoSuiteII_QueryVersion (
  41. IN PCSTR *ExeNamesBuf
  42. )
  43. {
  44. HKEY key = NULL;
  45. PCTSTR fullFileName = NULL;
  46. PCTSTR fileName = NULL;
  47. DWORD result = ERROR_SUCCESS;
  48. MultiSzAppendA (&g_FilesBuff, S_PHOTOSII_FILE1);
  49. *ExeNamesBuf = g_FilesBuff.Buf;
  50. return result;
  51. }
  52. LONG
  53. PhotoSuiteII_Initialize9x (
  54. IN PCSTR WorkingDirectory,
  55. IN PCSTR SourceDirectories
  56. )
  57. {
  58. INFSTRUCT context = INITINFSTRUCT_GROWBUFFER;
  59. PCSTR fullFileName = NULL;
  60. PCSTR fileName = NULL;
  61. PCSTR companyName = NULL;
  62. PCSTR productVer = NULL;
  63. LONG result = ERROR_NOT_INSTALLED;
  64. //
  65. // Let's find out where are our files located
  66. //
  67. if (g_MigrateInf != INVALID_HANDLE_VALUE) {
  68. if (InfFindFirstLineA (g_MigrateInf, S_MIGRATION_PATHS, NULL, &context)) {
  69. do {
  70. fullFileName = InfGetStringFieldA (&context, 1);
  71. if (fullFileName) {
  72. __try {
  73. fileName = GetFileNameFromPathA (fullFileName);
  74. if (StringIMatchA (fileName, S_PHOTOSII_FILE1)) {
  75. companyName = QueryVersionEntry (fullFileName, S_COMPANYNAME);
  76. if ((!companyName) ||
  77. (!IsPatternMatchA (S_PHOTOSII_COMPANYNAME, companyName))
  78. ) {
  79. continue;
  80. }
  81. productVer = QueryVersionEntry (fullFileName, S_PRODUCTVER);
  82. if ((!productVer) ||
  83. (!IsPatternMatchA (S_PHOTOSII_PRODUCTVER, productVer))
  84. ) {
  85. continue;
  86. }
  87. result = ERROR_SUCCESS;
  88. MemDbSetValueExA (MEMDB_CATEGORY_PHOTOSII, fullFileName, NULL, NULL, 0, NULL);
  89. FreePathStringA (productVer);
  90. productVer = NULL;
  91. FreePathStringA (companyName);
  92. companyName = NULL;
  93. }
  94. }
  95. __finally {
  96. if (productVer) {
  97. FreePathStringA (productVer);
  98. productVer = NULL;
  99. }
  100. if (companyName) {
  101. FreePathStringA (companyName);
  102. companyName = NULL;
  103. }
  104. }
  105. }
  106. } while (InfFindNextLine (&context));
  107. InfCleanUpInfStruct (&context);
  108. }
  109. if (result == ERROR_NOT_INSTALLED) {
  110. DEBUGMSGA ((DBG_VERBOSE, "MGI PhotoSuite II migration DLL: Could not find needed files."));
  111. }
  112. } else {
  113. DEBUGMSGA ((DBG_ERROR, "MGI PhotoSuite II migration DLL: Could not open MIGRATE.INF."));
  114. }
  115. return result;
  116. }
  117. LONG
  118. PhotoSuiteII_MigrateUser9x (
  119. IN HWND ParentWnd,
  120. IN PCSTR UnattendFile,
  121. IN HKEY UserRegKey,
  122. IN PCSTR UserName
  123. )
  124. {
  125. return ERROR_SUCCESS;
  126. }
  127. LONG
  128. PhotoSuiteII_MigrateSystem9x (
  129. IN HWND ParentWnd,
  130. IN PCSTR UnattendFile
  131. )
  132. {
  133. return ERROR_SUCCESS;
  134. }
  135. LONG
  136. PhotoSuiteII_InitializeNT (
  137. IN PCWSTR WorkingDirectory,
  138. IN PCWSTR SourceDirectories
  139. )
  140. {
  141. return ERROR_SUCCESS;
  142. }
  143. LONG
  144. PhotoSuiteII_MigrateUserNT (
  145. IN HINF UnattendFile,
  146. IN HKEY UserRegKey,
  147. IN PCWSTR UserName
  148. )
  149. {
  150. return ERROR_SUCCESS;
  151. }
  152. LONG
  153. PhotoSuiteII_MigrateSystemNT (
  154. IN HINF UnattendFile
  155. )
  156. {
  157. MEMDB_ENUMA e;
  158. CHAR pattern[MEMDB_MAX];
  159. CHAR file1[MEMDB_MAX];
  160. CHAR file2[MEMDB_MAX];
  161. PSTR filePtr;
  162. MemDbBuildKeyA (pattern, MEMDB_CATEGORY_PHOTOSII, "*", NULL, NULL);
  163. if (MemDbEnumFirstValueA (&e, pattern, MEMDB_ALL_SUBLEVELS, MEMDB_ENDPOINTS_ONLY)) {
  164. do {
  165. //
  166. // we want to copy a file that is relative to this one
  167. //
  168. filePtr = _mbsrchr (e.szName, '\\');
  169. if (filePtr) {
  170. StringCopyABA (file1, e.szName, filePtr);
  171. } else {
  172. StringCopyA (file1, e.szName);
  173. }
  174. StringCopyA (file2, file1);
  175. StringCatA (file1, S_PHOTOSII_RELPATH1);
  176. StringCatA (file2, S_PHOTOSII_RELPATH2);
  177. StringCatA (file1, S_PHOTOSII_FILE2);
  178. StringCatA (file2, S_PHOTOSII_FILE2);
  179. if (!CopyFile (file1, file2, TRUE)) {
  180. DEBUGMSGA ((
  181. DBG_ERROR,
  182. "MGI PhotoSuite II migration DLL: Could not copy %s to %s. Error:%d",
  183. file1,
  184. file2,
  185. GetLastError ()
  186. ));
  187. }
  188. } while (MemDbEnumNextValueA (&e));
  189. }
  190. return ERROR_SUCCESS;
  191. }