Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

icmupg.c File Reference

#include "icmupg.h"
#include "msg.h"
#include <setupapi.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  tagMANUMODELIDS
struct  tagREGDATA
struct  VENDORINFO

Typedefs

typedef tagMANUMODELIDS MANUMODELIDS
typedef tagMANUMODELIDSPMANUMODELIDS
typedef tagREGDATA REGDATA
typedef tagREGDATAPREGDATA
typedef BOOL(WINAPI * PFNINSTALLCOLORPROFILEA )(PSTR, PSTR)
typedef BOOL(WINAPI * PFNINSTALLCOLORPROFILE )(LPCTSTR, LPCTSTR)
typedef BOOL(WINAPI * PFNENUMCOLORPROFILES )(PCTSTR, PENUMTYPE, PBYTE, PDWORD, PDWORD)
typedef * PVENDORINFO

Functions

VOID InternalUpgradeICM ()
VOID UpgradeClass (HKEY)
BOOL AssociateMonitorProfile ()
BOOL AssociatePrinterProfiles (HKEY)
VOID InstallProfiles ()
VOID DeleteOldICMKey ()
void GetManuAndModelIDs (PTSTR, DWORD *, DWORD *)
int lstrcmpn (PTSTR, PTSTR, DWORD)
BOOL WINAPI DllEntryPoint (HINSTANCE hinstDll, DWORD dwReason, LPVOID lpReserved)
LONG CALLBACK QueryVersion (OUT LPCSTR *pszProductID, OUT LPUINT puDllVersion, OUT LPINT *pCodePageArray, OPTIONAL OUT LPCSTR *ppszExeNamesBuf, OPTIONAL OUT PVENDORINFO *ppVendorInfo)
LONG CALLBACK Initialize9x (IN LPCSTR pszWorkingDir, IN LPCSTR pszSourceDir, IN LPVOID pvReserved)
LONG CALLBACK MigrateUser9x (IN HWND hwndParent, IN LPCSTR pszUnattendFile, IN HKEY hUserRegKey, IN LPCSTR pszUserName, LPVOID pvReserved)
LONG CALLBACK MigrateSystem9x (IN HWND hwndParent, IN LPCSTR pszUnattendFile, LPVOID pvReserved)
LONG CALLBACK InitializeNT (IN LPCWSTR pszWorkingDir, IN LPCWSTR pszSourceDir, LPVOID pvReserved)
LONG CALLBACK MigrateUserNT (IN HANDLE hUnattendInf, IN HKEY hUserRegKey, IN LPCWSTR pszUserName, LPVOID pvReserved)
LONG CALLBACK MigrateSystemNT (IN HANDLE hUnattendInf, LPVOID pvReserved)
void MyMoveDir (char *s, char *d)

Variables

TCHAR const gszICMRegPath [] = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ICM"
TCHAR const gszProfile [] = "profile"
TCHAR const gszMSCMSdll [] = "mscms.dll"
char const gszProductID [] = "Microsoft Color Management System"
char const gszInstallColorProfile [] = "InstallColorProfileA"
char const gszGetColorDirectory [] = "GetColorDirectoryA"
char const gszEnumColorProfiles [] = "EnumColorProfilesA"
VENDORINFO gVendorInfo
char gszMigInf [MAX_PATH]
char const gszFullICMRegPath [] = "\"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ICM\""
char const gszInstallColorProfileA [] = "InstallColorProfileA"
TCHAR szValue [MAX_PATH]
TCHAR szName [MAX_PATH]
PFNINSTALLCOLORPROFILEA pInstallColorProfileA = NULL
PFNINSTALLCOLORPROFILE pInstallColorProfile = NULL
PFNENUMCOLORPROFILES pEnumColorProfiles = NULL
HINSTANCE hinstMigDll


Typedef Documentation

typedef struct tagMANUMODELIDS MANUMODELIDS
 

typedef BOOL(WINAPI * PFNENUMCOLORPROFILES)(PCTSTR, PENUMTYPE, PBYTE, PDWORD, PDWORD)
 

Definition at line 51 of file icmupg.c.

Referenced by MigrateSystem9x().

typedef BOOL(WINAPI * PFNINSTALLCOLORPROFILE)(LPCTSTR, LPCTSTR)
 

Definition at line 50 of file icmupg.c.

Referenced by MigrateSystemNT().

typedef BOOL(WINAPI * PFNINSTALLCOLORPROFILEA)(PSTR, PSTR)
 

Definition at line 49 of file icmupg.c.

Referenced by MigrateSystemNT().

typedef struct tagMANUMODELIDS * PMANUMODELIDS
 

typedef struct tagREGDATA * PREGDATA
 

typedef * PVENDORINFO
 

typedef struct tagREGDATA REGDATA
 


Function Documentation

BOOL AssociateMonitorProfile  ) 
 

BOOL AssociatePrinterProfiles HKEY   ) 
 

VOID DeleteOldICMKey  ) 
 

Definition at line 600 of file icmupg.c.

References DWORD, gszICMRegPath, and NULL.

Referenced by MigrateSystemNT().

00601 { 00602 HKEY hkICM = NULL; // key to ICM branch in registry 00603 DWORD nSubkeys, i; 00604 TCHAR szKeyName[32]; 00605 00606 // 00607 // Open the registry path where profiles used to be kept 00608 // 00609 00610 if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, gszICMRegPath, 0, NULL, 00611 REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 00612 NULL, &hkICM, NULL) != ERROR_SUCCESS) 00613 { 00614 00615 SetupLogError("ICM Migration: Cannot open ICM branch of registry\r\n", LogSevError); 00616 return; 00617 } 00618 00619 if (RegQueryInfoKey(hkICM, NULL, NULL, 0, &nSubkeys, NULL, NULL, 00620 NULL, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) 00621 { 00622 SetupLogError("ICM Migration: Cannot enumerate ICM branch of registry\r\n", LogSevError); 00623 goto EndDeleteOldICMKey; 00624 } 00625 00626 // 00627 // Go through all the device classes and delete all subkeys - this should 00628 // only be one level deep 00629 // 00630 00631 for (i=nSubkeys; i>0; i--) 00632 { 00633 RegEnumKey(hkICM, i-1, szKeyName, sizeof(szKeyName)); 00634 RegDeleteKey(hkICM, szKeyName); 00635 } 00636 00637 EndDeleteOldICMKey: 00638 if (hkICM) 00639 { 00640 RegCloseKey(hkICM); 00641 } 00642 RegDeleteKey(HKEY_LOCAL_MACHINE, gszICMRegPath); 00643 00644 return; 00645 }

BOOL WINAPI DllEntryPoint HINSTANCE  hinstDll,
DWORD  dwReason,
LPVOID  lpReserved
 

Definition at line 110 of file icmupg.c.

References hinstMigDll, and TRUE.

00110 { 00111 if(dwReason==DLL_PROCESS_ATTACH) { 00112 hinstMigDll = hinstDll; 00113 } 00114 return TRUE; 00115 }

void GetManuAndModelIDs PTSTR  ,
DWORD ,
DWORD
 

LONG CALLBACK Initialize9x IN LPCSTR  pszWorkingDir,
IN LPCSTR  pszSourceDir,
IN LPVOID  pvReserved
 

Definition at line 215 of file icmupg.c.

References gszMigInf, and WARNING.

00220 { 00221 // 00222 // Lets figure out if we're on a Win98 or Win95 system 00223 // We don't migrate Win95 because Win95 doesn't have a 00224 // profile database to migrate. 00225 // 00226 00227 /* OSVERSIONINFO osVer; 00228 00229 osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 00230 GetVersionEx(&osVer); 00231 gbWin98 = 00232 (osVer.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && 00233 ( (osVer.dwMajorVersion > 4) || 00234 ( (osVer.dwMajorVersion == 4) && (osVer.dwMinorVersion > 0) ) ); 00235 */ 00236 WARNING((__TEXT("Initialize9x called\n"))); 00237 00238 lstrcpyA(gszMigInf, pszWorkingDir); 00239 lstrcatA(gszMigInf, "\\migrate.inf"); 00240 00241 return ERROR_SUCCESS; 00242 }

LONG CALLBACK InitializeNT IN LPCWSTR  pszWorkingDir,
IN LPCWSTR  pszSourceDir,
LPVOID  pvReserved
 

Definition at line 470 of file icmupg.c.

References FALSE.

00475 { 00476 SetupOpenLog(FALSE); 00477 SetupLogError("ICM Migration: InitializeNT called\r\n", LogSevInformation); 00478 return ERROR_SUCCESS; 00479 }

VOID InstallProfiles  ) 
 

Definition at line 726 of file icmupg.c.

References ASSERT, CHAR, gszMigInf, INVALID_HANDLE_VALUE, MAX_PATH, MyMoveDir(), NULL, pInstallColorProfileA, and sprintf().

Referenced by MigrateSystemNT().

00727 { 00728 WIN32_FIND_DATAA wfd; 00729 PSTR pNewColorDirEnd; 00730 HANDLE hFindFile; 00731 CHAR szOldColorDir[MAX_PATH]; 00732 CHAR szNewColorDir[MAX_PATH]; 00733 CHAR szReturnString[2]; 00734 CHAR szDefaultString[2]; 00735 CHAR szMessage[2*MAX_PATH+100]; 00736 00737 GetWindowsDirectoryA(szOldColorDir, MAX_PATH); 00738 if (szOldColorDir[lstrlenA(szOldColorDir)-1] != '\\') 00739 lstrcatA(szOldColorDir, "\\"); 00740 lstrcatA(szOldColorDir, "system\\color\\"); 00741 00742 00743 GetWindowsDirectoryA(szNewColorDir, MAX_PATH); 00744 if (szNewColorDir[lstrlenA(szNewColorDir)-1] != '\\') 00745 { 00746 lstrcatA(szNewColorDir, "\\"); 00747 } 00748 lstrcatA(szNewColorDir, "system32\\spool\\drivers\\color\\"); 00749 00750 ASSERT(pInstallColorProfileA != NULL); 00751 00752 00753 // 00754 // Eat any errors on the MoveFile. This is just in case the migration 00755 // was stopped after a previous move and now the source doesn't exist. 00756 // 00757 00758 MyMoveDir(szOldColorDir, szNewColorDir); 00759 00760 // 00761 // Now we have presumably moved everything so run through the list of 00762 // previously installed profiles and install those in the new directory 00763 // (if we find them). 00764 // 00765 00766 pNewColorDirEnd = szNewColorDir + lstrlenA(szNewColorDir); 00767 lstrcatA(szNewColorDir, "*.*"); 00768 00769 00770 00771 szDefaultString[0]='0'; 00772 szDefaultString[1]=0; 00773 hFindFile = FindFirstFileA(szNewColorDir, &wfd); 00774 00775 00776 if (hFindFile != INVALID_HANDLE_VALUE) 00777 { 00778 do 00779 { 00780 lstrcpyA(pNewColorDirEnd, wfd.cFileName); 00781 00782 // 00783 // Check to see if the profile was installed on Win9x 00784 // 00785 00786 GetPrivateProfileStringA("Installed ICM Profiles", wfd.cFileName, szDefaultString, szReturnString, 2, gszMigInf); 00787 00788 // 00789 // If it was installed, attempt to install it on NT 00790 // 00791 00792 if(szReturnString[0]=='1') { 00793 if (!(*pInstallColorProfileA)(NULL, szNewColorDir)) 00794 { 00795 sprintf(szMessage, "ICM Migration: Error %d installing profile %s\r\n", GetLastError(), szNewColorDir); 00796 SetupLogError(szMessage, LogSevError); 00797 } 00798 else 00799 { 00800 sprintf(szMessage, "ICM Migration: Installed profile %s\r\n", szNewColorDir); 00801 SetupLogError(szMessage, LogSevInformation); 00802 } 00803 } 00804 00805 } while (FindNextFileA(hFindFile, &wfd)); 00806 00807 FindClose(hFindFile); 00808 } 00809 else 00810 { 00811 SetupLogError("ICM Migration: FindFirstFile returned an invalid handle\r\n", LogSevFatalError); 00812 } 00813 }

VOID InternalUpgradeICM  ) 
 

Definition at line 833 of file icmupg.c.

References CHAR, gszICMRegPath, MAX_PATH, NULL, sprintf(), and UpgradeClass().

Referenced by MigrateSystemNT().

00834 { 00835 HKEY hkICM = NULL; // key to ICM branch in registry 00836 HKEY hkDevice = NULL; // key to ICM device branch in registry 00837 int i; // counter variable 00838 TCHAR *pszClasses[] = { // different profile classes 00839 __TEXT("mntr"), 00840 __TEXT("prtr"), 00841 __TEXT("scnr"), 00842 __TEXT("link"), 00843 __TEXT("abst"), 00844 __TEXT("spac"), 00845 __TEXT("nmcl") 00846 }; 00847 CHAR szMessage[MAX_PATH]; 00848 LONG errcode; 00849 00850 // 00851 // Open the registry path where profiles are kept 00852 // 00853 00854 if (errcode = RegCreateKeyEx(HKEY_LOCAL_MACHINE, gszICMRegPath, 0, NULL, 00855 REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, 00856 &hkICM, NULL) != ERROR_SUCCESS) 00857 { 00858 sprintf(szMessage, "ICM Migration: Fatal Error, cannot open registry entry (%s) code:%d\r\n", 00859 gszICMRegPath, errcode); 00860 SetupLogError(szMessage, LogSevFatalError); 00861 return; 00862 } 00863 00864 // 00865 // Go through all the device classes and install the profiles 00866 // 00867 00868 for (i=0; i<sizeof(pszClasses)/sizeof(PTSTR); i++) 00869 { 00870 if (RegOpenKeyEx(hkICM, pszClasses[i], 0, KEY_ALL_ACCESS, &hkDevice) != ERROR_SUCCESS) 00871 { 00872 continue; // go to next key 00873 } 00874 00875 sprintf(szMessage, "ICM Migration: Upgrading %s\r\n", pszClasses[i]); 00876 SetupLogError(szMessage, LogSevInformation); 00877 UpgradeClass(hkDevice); 00878 00879 RegCloseKey(hkDevice); 00880 } 00881 00882 // 00883 // Set default monitor profile 00884 // 00885 00886 // AssociateMonitorProfile(); - Not needed for Memphis 00887 // If Pnp moves everything from Win9x PnP S/W section to NT 5.0 PnP S/W 00888 // section, then we don't need this for NT either 00889 00890 if (hkICM) 00891 { 00892 RegCloseKey(hkICM); 00893 } 00894 00895 return; 00896 }

int lstrcmpn PTSTR  ,
PTSTR  ,
DWORD 
 

Definition at line 1048 of file icmupg.c.

Referenced by UpgradeClass().

01053 { 01054 // 01055 // Assume no NULL strings 01056 // 01057 01058 while (*pStr1 && *pStr2 && --dwLen) 01059 { 01060 if (*pStr1 != *pStr2) 01061 break; 01062 01063 pStr1++; 01064 pStr2++; 01065 } 01066 01067 return (int)(*pStr1 - *pStr2); 01068 }

LONG CALLBACK MigrateSystem9x IN HWND  hwndParent,
IN LPCSTR  pszUnattendFile,
LPVOID  pvReserved
 

Definition at line 296 of file icmupg.c.

References BYTE, DWORD, gszEnumColorProfiles, gszFullICMRegPath, gszMigInf, gszMSCMSdll, MAX_PATH, NULL, PBYTE, pEnumColorProfiles, PFNENUMCOLORPROFILES, and WARNING.

00301 { 00302 DWORD nProfiles; 00303 DWORD dwSize; 00304 char szColorDir[MAX_PATH]; 00305 char szNewColorDir[MAX_PATH]; 00306 char szDrive[2]; 00307 HMODULE hModule; 00308 ENUMTYPE et = {sizeof (ENUMTYPE), ENUM_TYPE_VERSION, 0, NULL}; 00309 PBYTE pBuffer; 00310 PSTR pstrBuffer; 00311 PSTR pstrTraversal; 00312 00313 WARNING((__TEXT("MigrateSystem9x called\n"))); 00314 00315 // 00316 // Produce the Win9x Color Directory. 00317 // 00318 00319 GetWindowsDirectoryA(szColorDir, MAX_PATH); 00320 if (szColorDir[lstrlenA(szColorDir)-1] != '\\') 00321 { 00322 lstrcatA(szColorDir,"\\"); 00323 } 00324 lstrcatA(szColorDir, "system\\color\\"); 00325 00326 GetWindowsDirectoryA(szNewColorDir, MAX_PATH); 00327 if (szNewColorDir[lstrlenA(szNewColorDir)-1] != '\\') 00328 { 00329 lstrcatA(szNewColorDir,"\\"); 00330 } 00331 lstrcatA(szNewColorDir, "system32\\spool\\drivers\\color\\"); 00332 00333 00334 // 00335 // If this is a Win95 system we have nothing to do because 00336 // Win95 doesn't have a color profile database. 00337 // 00338 00339 00340 // 00341 // We can't have mscms as an implib because when they try to load us in 00342 // Win95, they won't find mscms.dll and reject us. 00343 // 00344 00345 hModule = LoadLibrary(gszMSCMSdll); 00346 if (hModule) { 00347 #ifdef ICM_MIG_DEBUG 00348 WritePrivateProfileStringA("ICM Debug", "hModule", "not NULL", gszMigInf); 00349 WritePrivateProfileStringA("ICM Debug", "gbWin98", "TRUE", gszMigInf); 00350 #endif 00351 00352 pEnumColorProfiles = (PFNENUMCOLORPROFILES)GetProcAddress(hModule, gszEnumColorProfiles); 00353 if (pEnumColorProfiles) { 00354 00355 #ifdef ICM_MIG_DEBUG 00356 WritePrivateProfileStringA("ICM Debug", "pEnumColorProfiles", "not NULL", gszMigInf); 00357 #endif 00358 00359 // 00360 // Compute the size of the EnumColorProfiles buffer. 00361 // 00362 00363 dwSize = 0; 00364 pEnumColorProfiles(NULL, &et, NULL, &dwSize, &nProfiles); 00365 00366 if(dwSize==0) 00367 { 00368 #ifdef ICM_MIG_DEBUG 00369 WritePrivateProfileStringA("ICM Debug", "dwSize", "0", gszMigInf); 00370 #endif 00371 // 00372 // Need to exit - nothing to do if there are no profiles installed, 00373 // except to move the directory and registry settings. 00374 // 00375 WARNING((__TEXT("No profiles installed\n"))); 00376 goto EndMigrateSystem9x; 00377 } 00378 00379 00380 // 00381 // Enumerate all the currently installed color profiles. 00382 // 00383 00384 #ifdef ICM_MIG_DEBUG 00385 WritePrivateProfileStringA("ICM Debug", "Enumerate", "Start", gszMigInf); 00386 #endif 00387 00388 pBuffer = (BYTE *)malloc(dwSize); 00389 pstrBuffer = (PSTR)pBuffer; 00390 00391 #ifdef ICM_MIG_DEBUG 00392 WritePrivateProfileStringA("ICM Debug", "Enumerate", "TRUE", gszMigInf); 00393 #endif 00394 00395 if(pEnumColorProfiles(NULL, &et, pBuffer, &dwSize, &nProfiles)) 00396 { 00397 #ifdef ICM_MIG_DEBUG 00398 WritePrivateProfileStringA("ICM Debug", "Enumerate", "for", gszMigInf); 00399 #endif 00400 00401 for(pstrTraversal = pstrBuffer; 00402 nProfiles--; 00403 pstrTraversal += 1 + lstrlenA(pstrTraversal)) { 00404 00405 // 00406 // Write the fact into the Migration Information file. 00407 // 00408 00409 WritePrivateProfileStringA("Installed ICM Profiles", pstrTraversal, "1", gszMigInf); 00410 } 00411 } 00412 free(pBuffer); 00413 } 00414 #ifdef ICM_MIG_DEBUG 00415 else { 00416 WritePrivateProfileStringA("ICM Debug", "pEnumColorProfiles", "NULL", gszMigInf); 00417 } 00418 #endif 00419 00420 00421 EndMigrateSystem9x: 00422 if (hModule) 00423 { 00424 FreeLibrary(hModule); 00425 } 00426 } 00427 #ifdef ICM_MIG_DEBUG 00428 else { 00429 WritePrivateProfileStringA("ICM Debug", "hModule", "NULL", gszMigInf); 00430 WritePrivateProfileStringA("ICM Debug", "gbWin98", "FALSE", gszMigInf); 00431 } 00432 #endif 00433 00434 // 00435 // We'll handle the ICM branch of the registry 00436 // 00437 00438 WritePrivateProfileStringA("Handled", gszFullICMRegPath, "Registry", gszMigInf); 00439 00440 00441 // 00442 // We'll be moving the entire subdirectory. 00443 // 00444 00445 WritePrivateProfileStringA("Moved", szColorDir, szNewColorDir, gszMigInf); 00446 00447 00448 return ERROR_SUCCESS; 00449 }

LONG CALLBACK MigrateSystemNT IN HANDLE  hUnattendInf,
LPVOID  pvReserved
 

Definition at line 534 of file icmupg.c.

References CHAR, DeleteOldICMKey(), gszInstallColorProfile, gszInstallColorProfileA, gszMSCMSdll, InstallProfiles(), InternalUpgradeICM(), MAX_PATH, PFNINSTALLCOLORPROFILE, PFNINSTALLCOLORPROFILEA, pInstallColorProfile, pInstallColorProfileA, and sprintf().

00538 { 00539 HINSTANCE hModule; 00540 LONG rc = ERROR_FILE_NOT_FOUND; 00541 CHAR szMessage[MAX_PATH]; 00542 00543 SetupLogError("ICM Migration: MigrateSystemNT called\r\n", LogSevInformation); 00544 00545 // 00546 // We can't have mscms as an implib because when they try to load us in 00547 // Win95, they won't find mscms.dll and reject us. 00548 // 00549 00550 hModule = LoadLibrary(gszMSCMSdll); 00551 if (!hModule) 00552 { 00553 sprintf(szMessage, "ICM Migration: Fatal Error, cannot load mscms.dll. Error %d\r\n", GetLastError()); 00554 SetupLogError(szMessage, LogSevFatalError); 00555 return rc; 00556 } 00557 00558 pInstallColorProfileA = (PFNINSTALLCOLORPROFILEA)GetProcAddress(hModule, gszInstallColorProfileA); 00559 pInstallColorProfile = (PFNINSTALLCOLORPROFILE)GetProcAddress(hModule, gszInstallColorProfile); 00560 00561 if (!pInstallColorProfile || !pInstallColorProfileA) 00562 { 00563 SetupLogError("ICM Migration: Fatal Error, cannot find mscms functions. \r\n", LogSevFatalError); 00564 goto EndMigrateSystemNT; 00565 } 00566 00567 InternalUpgradeICM(); // Upgrade over Win9x 00568 InstallProfiles(); // Install all profiles in the old color directory 00569 DeleteOldICMKey(); 00570 00571 rc = ERROR_SUCCESS; 00572 00573 EndMigrateSystemNT: 00574 00575 if (hModule) 00576 { 00577 FreeLibrary(hModule); 00578 } 00579 00580 return rc; 00581 }

LONG CALLBACK MigrateUser9x IN HWND  hwndParent,
IN LPCSTR  pszUnattendFile,
IN HKEY  hUserRegKey,
IN LPCSTR  pszUserName,
LPVOID  pvReserved
 

Definition at line 262 of file icmupg.c.

References WARNING.

00269 { 00270 // 00271 // Nothing to do 00272 // 00273 00274 WARNING((__TEXT("MigrateUser9x called\n"))); 00275 return ERROR_SUCCESS; 00276 }

LONG CALLBACK MigrateUserNT IN HANDLE  hUnattendInf,
IN HKEY  hUserRegKey,
IN LPCWSTR  pszUserName,
LPVOID  pvReserved
 

Definition at line 499 of file icmupg.c.

00505 { 00506 SetupLogError("ICM Migration: MigrateUserNT called\r\n", LogSevInformation); 00507 00508 // 00509 // Nothing to do 00510 // 00511 00512 return ERROR_SUCCESS; 00513 }

void MyMoveDir char *  s,
char *  d
 

Definition at line 665 of file icmupg.c.

References MAX_PATH, and sprintf().

Referenced by InstallProfiles().

00665 { 00666 WIN32_FIND_DATA rf; 00667 HANDLE hf; 00668 char s2[MAX_PATH]; 00669 char s_[MAX_PATH]; 00670 char d_[MAX_PATH]; 00671 char err[MAX_PATH]; 00672 00673 // 00674 // If MoveFileEx succeeds, we're done. 00675 // 00676 00677 if(!MoveFileEx(s, d, MOVEFILE_REPLACE_EXISTING)) { 00678 sprintf(s2, "%s*", s); 00679 hf = FindFirstFile(s2, &rf); 00680 do { 00681 // don't move . and .. 00682 if(!(strcmp(".", rf.cFileName)==0 || 00683 strcmp("..", rf.cFileName)==0) ) { 00684 sprintf(s_, "%s%s", s, rf.cFileName); 00685 sprintf(d_, "%s%s", d, rf.cFileName); 00686 if(!MoveFileEx(s_, d_, MOVEFILE_REPLACE_EXISTING)) { 00687 int e = GetLastError(); 00688 sprintf(err, "ICM Migration: Failed the move of %s with %d\r\n", s_, e); 00689 SetupLogError(err, LogSevError); 00690 } else { 00691 sprintf(err, "ICM Migration: Moved %s to %s\n", s_, d_); 00692 SetupLogError(err, LogSevInformation); 00693 } 00694 } 00695 00696 } while(FindNextFile(hf, &rf)); 00697 FindClose(hf); 00698 } 00699 00700 // 00701 // source directory should theoretically be empty at this point 00702 // If there are errors, we'll leave files behind and report this in 00703 // the setup log as a LogSevError. 00704 // 00705 }

LONG CALLBACK QueryVersion OUT LPCSTR *  pszProductID,
OUT LPUINT  puDllVersion,
OUT LPINT *  pCodePageArray,
OPTIONAL OUT LPCSTR *  ppszExeNamesBuf,
OPTIONAL OUT PVENDORINFO ppVendorInfo
 

Definition at line 139 of file icmupg.c.

References VENDORINFO::CompanyName, gszProductID, gVendorInfo, hinstMigDll, VENDORINFO::InstructionsToUser, NULL, VENDORINFO::SupportNumber, VENDORINFO::SupportUrl, and WARNING.

00146 { 00147 *pszProductID = gszProductID; 00148 *puDllVersion = 1; 00149 *ppszExeNamesBuf = NULL; 00150 *pCodePageArray = NULL; 00151 *ppVendorInfo = &gVendorInfo; 00152 memset(&gVendorInfo, 0, sizeof(VENDORINFO)); 00153 FormatMessageA( 00154 FORMAT_MESSAGE_FROM_HMODULE, 00155 hinstMigDll, 00156 MSG_VI_COMPANY_NAME, 00157 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 00158 gVendorInfo.CompanyName, 00159 sizeof(gVendorInfo.CompanyName), 00160 NULL 00161 ); 00162 00163 FormatMessageA( 00164 FORMAT_MESSAGE_FROM_HMODULE, 00165 hinstMigDll, 00166 MSG_VI_SUPPORT_NUMBER, 00167 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 00168 gVendorInfo.SupportNumber, 00169 sizeof(gVendorInfo.SupportNumber), 00170 NULL 00171 ); 00172 00173 FormatMessageA( 00174 FORMAT_MESSAGE_FROM_HMODULE, 00175 hinstMigDll, 00176 MSG_VI_SUPPORT_URL, 00177 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 00178 gVendorInfo.SupportUrl, 00179 sizeof(gVendorInfo.SupportUrl), 00180 NULL 00181 ); 00182 00183 FormatMessageA( 00184 FORMAT_MESSAGE_FROM_HMODULE, 00185 hinstMigDll, 00186 MSG_VI_INSTRUCTIONS, 00187 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 00188 gVendorInfo.InstructionsToUser, 00189 sizeof(gVendorInfo.InstructionsToUser), 00190 NULL 00191 ); 00192 WARNING((__TEXT("QueryVersion called\n"))); 00193 return ERROR_SUCCESS; 00194 }

VOID UpgradeClass HKEY   ) 
 

Definition at line 916 of file icmupg.c.

References ASSERT, CHAR, DWORD, gszProfile, lstrcmpn(), MAX_PATH, NULL, pInstallColorProfile, sprintf(), szName, and szValue.

Referenced by InternalUpgradeICM().

00919 { 00920 HKEY hSubkey; 00921 DWORD nSubkeys, nValues, i, cbName, cbValue; 00922 TCHAR szKeyName[32]; 00923 CHAR szMessage[MAX_PATH]; 00924 00925 // 00926 // If there is an error, return 00927 // 00928 00929 if (RegQueryInfoKey(hKey, NULL, NULL, 0, &nSubkeys, NULL, NULL, 00930 &nValues, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) 00931 { 00932 return; 00933 } 00934 00935 if (nSubkeys > 0) 00936 { 00937 // 00938 // This is not the leaf node, recurse 00939 // 00940 00941 for (i=nSubkeys; i>0; i--) 00942 { 00943 RegEnumKey(hKey, i-1, szKeyName, sizeof(szKeyName)); 00944 if (RegOpenKeyEx(hKey, szKeyName, 0, KEY_ALL_ACCESS, &hSubkey) == ERROR_SUCCESS) 00945 { 00946 UpgradeClass(hSubkey); 00947 RegCloseKey(hSubkey); 00948 RegDeleteKey(hKey, szKeyName); 00949 } 00950 } 00951 } 00952 else 00953 { 00954 // 00955 // This is the leaf node - install all the profiles registered 00956 // 00957 00958 ASSERT(pInstallColorProfile != NULL); 00959 00960 for (i=nValues; i>0; i--) 00961 { 00962 cbName = MAX_PATH; 00963 cbValue = MAX_PATH; 00964 if (RegEnumValue(hKey, i-1, szName, &cbName, 0, NULL, (LPBYTE)szValue, 00965 &cbValue) == ERROR_SUCCESS) 00966 { 00967 if (! lstrcmpn(szName, (PTSTR)gszProfile, lstrlen(gszProfile))) 00968 { 00969 if (! (*pInstallColorProfile)(NULL, szValue)) 00970 { 00971 sprintf(szMessage, "ICM Migration: Error installing profile %s\r\n", szValue); 00972 SetupLogError(szMessage, LogSevError); 00973 } 00974 else 00975 { 00976 sprintf(szMessage, "ICM Migration: Installed profile %s\r\n", szValue); 00977 SetupLogError(szMessage, LogSevInformation); 00978 } 00979 } 00980 else 00981 { 00982 PTSTR pProfile; 00983 00984 // 00985 // We might be upgrading over Memphis or later 00986 // In Memphis it is "file name" "value" instead of 00987 // "profilexx" "value" in Win95 & OSR2 00988 // 00989 00990 if (szName[1] == ':') 00991 { 00992 // 00993 // Assume full path name 00994 // 00995 00996 pProfile = szName; 00997 00998 } 00999 else 01000 { 01001 GetWindowsDirectory(szValue, MAX_PATH); 01002 if (szValue[lstrlen(szValue)-1] != '\\') 01003 lstrcat(szValue, __TEXT("\\")); 01004 lstrcat(szValue, __TEXT("system\\color\\")); 01005 lstrcat(szValue, szName); 01006 pProfile = szValue; 01007 } 01008 01009 if (! (*pInstallColorProfile)(NULL, pProfile)) 01010 { 01011 sprintf(szMessage, "ICM Migration: Error installing profile %s\r\n", pProfile); 01012 SetupLogError(szMessage, LogSevError); 01013 } 01014 else 01015 { 01016 sprintf(szMessage, "ICM Migration: Installed Profile %s\r\n", pProfile); 01017 SetupLogError(szMessage, LogSevInformation); 01018 } 01019 } 01020 RegDeleteValue(hKey, szName); 01021 } 01022 } 01023 } 01024 01025 return; 01026 }


Variable Documentation

char const gszEnumColorProfiles[] = "EnumColorProfilesA"
 

Definition at line 73 of file icmupg.c.

Referenced by MigrateSystem9x().

char const gszFullICMRegPath[] = "\"HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ICM\""
 

Definition at line 76 of file icmupg.c.

Referenced by MigrateSystem9x().

char const gszGetColorDirectory[] = "GetColorDirectoryA"
 

Definition at line 72 of file icmupg.c.

TCHAR const gszICMRegPath[] = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ICM"
 

Definition at line 65 of file icmupg.c.

Referenced by DeleteOldICMKey(), GetMonitorData(), InternalAssociateColorProfileWithDevice(), InternalDisassociateColorProfileFromDevice(), InternalEnumColorProfiles(), InternalGetSCSProfile(), InternalInstallColorProfile(), InternalSetSCSProfile(), InternalUninstallColorProfile(), InternalUpgradeICM(), and OpenMonitor().

char const gszInstallColorProfile[] = "InstallColorProfileA"
 

Definition at line 71 of file icmupg.c.

Referenced by MigrateSystemNT().

char const gszInstallColorProfileA[] = "InstallColorProfileA"
 

Definition at line 78 of file icmupg.c.

Referenced by MigrateSystemNT().

char gszMigInf[MAX_PATH]
 

Definition at line 75 of file icmupg.c.

Referenced by Initialize9x(), InstallProfiles(), and MigrateSystem9x().

TCHAR const gszMSCMSdll[] = "mscms.dll"
 

Definition at line 67 of file icmupg.c.

Referenced by MigrateSystem9x(), and MigrateSystemNT().

char const gszProductID[] = "Microsoft Color Management System"
 

Definition at line 69 of file icmupg.c.

Referenced by QueryVersion().

TCHAR const gszProfile[] = "profile"
 

Definition at line 66 of file icmupg.c.

Referenced by UpgradeClass().

VENDORINFO gVendorInfo
 

Definition at line 74 of file icmupg.c.

Referenced by QueryVersion().

HINSTANCE hinstMigDll
 

Definition at line 106 of file icmupg.c.

Referenced by DllEntryPoint(), and QueryVersion().

PFNENUMCOLORPROFILES pEnumColorProfiles = NULL
 

Definition at line 91 of file icmupg.c.

Referenced by MigrateSystem9x().

PFNINSTALLCOLORPROFILE pInstallColorProfile = NULL
 

Definition at line 90 of file icmupg.c.

Referenced by MigrateSystemNT(), and UpgradeClass().

PFNINSTALLCOLORPROFILEA pInstallColorProfileA = NULL
 

Definition at line 89 of file icmupg.c.

Referenced by InstallProfiles(), and MigrateSystemNT().

TCHAR szName[MAX_PATH]
 

Definition at line 87 of file icmupg.c.

Referenced by CScannerList::Enumerate(), InitiateWin32kCleanup(), OpenMonitor(), RawInputThread(), UpgradeClass(), and vCheckMMInstance().

TCHAR szValue[MAX_PATH]
 

Definition at line 86 of file icmupg.c.

Referenced by UpgradeClass().


Generated on Sat May 15 19:44:09 2004 for test by doxygen 1.3.7