//--------------------------------------------------------------------------- // This file is modified by Maxleo21c(Park Sang Hoon). // It works in C++ Builder 6. // 2004. 07. 15. // Reference : Program by Hans Dietrich //--------------------------------------------------------------------------- #include "tchar.h" #include "Registry.hpp" #pragma hdrstop #include "GetVectorFontName.h" //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- // from winbase.h #ifndef VER_PLATFORM_WIN32s #define VER_PLATFORM_WIN32s 0 #endif #ifndef VER_PLATFORM_WIN32_WINDOWS #define VER_PLATFORM_WIN32_WINDOWS 1 #endif #ifndef VER_PLATFORM_WIN32_NT #define VER_PLATFORM_WIN32_NT 2 #endif #ifndef VER_PLATFORM_WIN32_CE #define VER_PLATFORM_WIN32_CE 3 #endif //--------------------------------------------------------------------------- /* This table has been assembled from Usenet postings, personal observations, and reading other people's code. Please feel free to add to it or correct it. dwPlatFormID dwMajorVersion dwMinorVersion dwBuildNumber 95 1 4 0 950 95 SP1 1 4 0 >950 && <=1080 95 OSR2 1 4 <10 >1080 98 1 4 10 1998 98 SP1 1 4 10 >1998 && <2183 98 SE 1 4 10 >=2183 ME 1 4 90 3000 NT 3.51 2 3 51 NT 4 2 4 0 1381 2000 2 5 0 2195 XP 2 5 1 CE 3 */ //--------------------------------------------------------------------------- TGetVectorFontName *GetVectorFontName; //--------------------------------------------------------------------------- __fastcall TGetVectorFontName::TGetVectorFontName() { VectorFontName = new TStringList; VectorFontName->Clear(); GetRegFontName(); } //--------------------------------------------------------------------------- __fastcall TGetVectorFontName::~TGetVectorFontName() { delete VectorFontName; delete RegFonts; } //--------------------------------------------------------------------------- // GetWinVer bool __fastcall TGetVectorFontName::GetWinVer(String &strVersion, int *nVersion) { strVersion = WUNKNOWNSTR; *nVersion = WUNKNOWN; OSVERSIONINFO osinfo; osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (!GetVersionEx(&osinfo)) return false; DWORD dwPlatformId = osinfo.dwPlatformId; DWORD dwMinorVersion = osinfo.dwMinorVersion; DWORD dwMajorVersion = osinfo.dwMajorVersion; DWORD dwBuildNumber = osinfo.dwBuildNumber & 0xFFFF; // Win 95 needs this if ((dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && (dwMajorVersion == 4)) { if ((dwMinorVersion < 10) && (dwBuildNumber == 950)) { strVersion = W95STR; *nVersion = W95; } else if ((dwMinorVersion < 10) && ((dwBuildNumber > 950) && (dwBuildNumber <= 1080))) { strVersion = W95SP1STR; *nVersion = W95SP1; } else if ((dwMinorVersion < 10) && (dwBuildNumber > 1080)) { strVersion = W95OSR2STR; *nVersion = W95OSR2; } else if ((dwMinorVersion == 10) && (dwBuildNumber == 1998)) { strVersion = W98STR; *nVersion = W98; } else if ((dwMinorVersion == 10) && ((dwBuildNumber > 1998) && (dwBuildNumber < 2183))) { strVersion = W98SP1STR; *nVersion = W98SP1; } else if ((dwMinorVersion == 10) && (dwBuildNumber >= 2183)) { strVersion = W98SESTR; *nVersion = W98SE; } else if (dwMinorVersion == 90) { strVersion = WMESTR; *nVersion = WME; } } else if (dwPlatformId == VER_PLATFORM_WIN32_NT) { if ((dwMajorVersion == 3) && (dwMinorVersion == 51)) { strVersion = WNT351STR; *nVersion = WNT351; } else if ((dwMajorVersion == 4) && (dwMinorVersion == 0)) { strVersion = WNT4STR; *nVersion = WNT4; } else if ((dwMajorVersion == 5) && (dwMinorVersion == 0)) { strVersion = W2KSTR; *nVersion = W2K; } else if ((dwMajorVersion == 5) && (dwMinorVersion == 1)) { strVersion = WXPSTR; *nVersion = WXP; } else if ((dwMajorVersion == 5) && (dwMinorVersion == 2)) { strVersion = WSERVER2003STR; *nVersion = WSERVER2003; //GetSystemMetrics(SM_SERVERR2) != 0 => Windows Server 2003 R2 //GetSystemMetrics(SM_SERVERR2) == 0 => Windows Server 2003 } else if ((dwMajorVersion == 6) && (dwMinorVersion == 0)) { strVersion = WVISTA32STR; *nVersion = WVISTA32; //OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION => Windows Server 2008 //OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION => Windows Vista } else if ((dwMajorVersion == 6) && (dwMinorVersion == 1)) { strVersion = WINDOWS7_32STR; *nVersion = WINDOWS7_32; //OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION => Windows Server 2008 R2 //OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION => Windows 7 } else if ((dwMajorVersion == 6) && (dwMinorVersion == 2)) { strVersion = WINDOWS8_32STR; *nVersion = WINDOWS8_32; } else if ((dwMajorVersion == 6) && (dwMinorVersion == 3)) { strVersion = WINDOWS8_1_32STR; *nVersion = WINDOWS8_1_32; //OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION => Windows Server 2012 R2 //OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION => Windows 8.1 } else if ((dwMajorVersion == 10) && (dwMinorVersion == 0)) { strVersion = WINDOWS10_32STR; *nVersion = WINDOWS10_32; //OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION => Windows Server 2016 //OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION => Windows 10 } } else if (dwPlatformId == VER_PLATFORM_WIN32_CE) { strVersion = WCESTR; *nVersion = WCE; } return true; } //--------------------------------------------------------------------------- void __fastcall TGetVectorFontName::GetRegFontName() { LPTSTR strFont; int nVersion; String strVersion; GetWinVer(strVersion, &nVersion); if ((nVersion >= WNTFIRST) && (nVersion <= WNTLAST)) strFont = L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"; else strFont = L"Software\\Microsoft\\Windows\\CurrentVersion\\Fonts"; String strKey = String(strFont) + "\\"; TRegIniFile *rifRegistry = new TRegIniFile(strFont); RegFonts = new TStringList; rifRegistry->RootKey = HKEY_LOCAL_MACHINE; rifRegistry->ReadSection(strKey, RegFonts); if (rifRegistry) delete rifRegistry; rifRegistry = NULL; } //--------------------------------------------------------------------------- void __fastcall TGetVectorFontName::GetVectorFont(LPTSTR lpszFontName) { bool check = false; String truetype = L"TrueType"; String opentype = L"OpenType"; String sourceString = lpszFontName, sourceString2; String tempString = NULL; if (sourceString == "±¼¸²") { lpszFontName = L"Gulim"; check = true; } else if (sourceString == "±¼¸²Ã¼") { lpszFontName = L"GulimChe"; check = true; } else if (sourceString == "µ¸¿ò") { lpszFontName = L"Dotum"; check = true; } else if (sourceString == "µ¸¿òü") { lpszFontName = L"DotumChe"; check = true; } else if (sourceString == "¹ÙÅÁ") { lpszFontName = L"Batang"; check = true; } else if (sourceString == "¹ÙÅÁü") { lpszFontName = L"BatangChe"; check = true; } else if (sourceString == "±Ã¼­") { lpszFontName = L"Gungsuh"; check = true; } else if (sourceString == "±Ã¼­Ã¼") { lpszFontName = L"GungsuhChe"; check = true; } sourceString2 = lpszFontName; //Vista¿¡¼­´Â Registry Fonts¿¡ Çѱ۷ΠǥÇöµÇ¾î ÀÖÁö ¾Ê¾Æ¼­ ÀÌ·¸°Ô ó¸® 07.03.08 for (int i = 0; i < RegFonts->Count; i++){ tempString = RegFonts->Strings[i]; if (!check && tempString.Pos("&")) check = true; if (check) { int index = tempString.Pos(sourceString2); if (index) { tempString = tempString.SubString(index, tempString.Length()-index+1); break; } } if (_tcsncmp(lpszFontName, RegFonts->Strings[i].c_str(), _tcslen(lpszFontName)) == 0) { break; } } if (tempString.IsEmpty() == false){ if (tempString.Pos(truetype) || tempString.Pos(opentype)) { if (_tcscmp(sourceString.c_str(), L"Courier")!=0) VectorFontName->Add(sourceString); } } } //--------------------------------------------------------------------------- String ChangeEnglishFontName(String sourceString) { String strRtn = sourceString; LANGID id = GetSystemDefaultLangID(); if (id == 0x0412) { // 1042 ÇÑ±Û À©µµ¿ìÀ϶§¸¸ üũ if (sourceString == "Gulim") { strRtn = "±¼¸²"; } else if (sourceString == "GulimChe") { strRtn = "±¼¸²Ã¼"; } else if (sourceString == "Dotum") { strRtn = "µ¸¿ò"; } else if (sourceString == "DotumChe") { strRtn = "µ¸¿òü"; } else if (sourceString == "Batang") { strRtn = "¹ÙÅÁ"; } else if (sourceString == "BatangChe") { strRtn = "¹ÙÅÁü"; } else if (sourceString == "Gungsuh") { strRtn = "±Ã¼­"; } else if (sourceString == "GungsuhChe") { strRtn = "±Ã¼­Ã¼"; } } return strRtn; } //---------------------------------------------------------------------------