gPref->SetIntPref( "browser.display.screen_resolution", prefVal );
InitGlobals(void){#ifdef WINCODE  nsServiceManager::GetService(kCharsetConverterManagerCID,    NS_GET_IID(nsICharsetConverterManager2), (nsISupports**) &gCharsetManager);  if (!gCharsetManager) {    FreeGlobals();    return NS_ERROR_FAILURE;  }#endif  nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref),    (nsISupports**) &gPref);  if (!gPref) {    FreeGlobals();    return NS_ERROR_FAILURE;  }  nsCOMPtr<nsILanguageAtomService> langService;  langService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);  if (langService) {    langService->GetLocaleLanguageGroup(&gUsersLocale);  }  if (!gUsersLocale) {    gUsersLocale = NS_NewAtom("x-western");  }  if (!gUsersLocale) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  gUserDefined = NS_NewAtom(USER_DEFINED);  if (!gUserDefined) {    FreeGlobals();    return NS_ERROR_OUT_OF_MEMORY;  }  ULONG numCP = ::WinQueryCpList((HAB)0, 0, NULL);  UniChar codepage[20];  if (numCP > 0) {     ULONG * pCPList = (ULONG*)nsMemory::Alloc(numCP*sizeof(ULONG));     if (::WinQueryCpList( (HAB)0, numCP, pCPList)) {        for (int i = 0;i<numCP ;i++ ) {           if (pCPList[i] == 1386) {              int unirc = ::UniMapCpToUcsCp( 1386, codepage, 20);              if (unirc == ULS_SUCCESS) {                 UconvObject Converter = 0;                 int unirc = ::UniCreateUconvObject( codepage, &Converter);                 if (unirc == ULS_SUCCESS) {                    gCharsetInfo[11].mCodePage = 1386;                   ::UniFreeUconvObject(Converter);                 }              }           } else if (pCPList[i] == 943) {              int unirc = ::UniMapCpToUcsCp( 943, codepage, 20);              if (unirc == ULS_SUCCESS) {                 UconvObject Converter = 0;                 int unirc = ::UniCreateUconvObject( codepage, &Converter);                 if (unirc == ULS_SUCCESS) {                    gCharsetInfo[10].mCodePage = 943;                   ::UniFreeUconvObject(Converter);                 }              }           }        }     }     nsMemory::Free(pCPList);  }  ulSystemCodePage = WinQueryCp(HMQ_CURRENT);   // find system screen resolution. used here and in RealizeFont  HPS ps = ::WinGetScreenPS(HWND_DESKTOP);  HDC hdc = GFX (::GpiQueryDevice (ps), HDC_ERROR);  GFX (::DevQueryCaps(hdc, CAPS_HORIZONTAL_FONT_RES, 1, &nsFontMetricsOS2::gSystemRes), FALSE);  ::WinReleasePS(ps);  if (!nsFontMetricsOS2::gGlobalFonts) {    if (!nsFontMetricsOS2::InitializeGlobalFonts()) {      FreeGlobals();      return NS_ERROR_OUT_OF_MEMORY;    }  }  // Set prefVal the value of the pref "browser.display.screen_resolution"  // When a new profile is created, the pref is set to 0.  This tells the code  // to default to font resolution of the screen (96 or 120)  nsresult res;  PRInt32 prefVal = -1;  res = gPref->GetIntPref( "browser.display.screen_resolution", &prefVal );  if (NS_FAILED(res))    prefVal = 0;  gPref->RegisterCallback( "browser.display.screen_resolution", prefChanged, NULL );  if( prefVal == 0 )  {    prefVal = nsFontMetricsOS2::gSystemRes;    gPref->SetIntPref( "browser.display.screen_resolution", prefVal );  }  nsFontMetricsOS2::gDPI = prefVal;  //register an observer to take care of cleanup  gFontCleanupObserver = new nsFontCleanupObserver();  NS_ASSERTION(gFontCleanupObserver, "failed to create observer");  if (gFontCleanupObserver) {    // register for shutdown    nsresult rv;    nsCOMPtr<nsIObserverService> observerService(do_GetService("@mozilla.org/observer-service;1", &rv));    if (NS_SUCCEEDED(rv)) {      rv = observerService->AddObserver(gFontCleanupObserver, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);    }      }    gInitialized = 1;  return NS_OK;}