Leaked source code of windows server 2003
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.

162 lines
4.2 KiB

  1. #include <windows.h>
  2. BOOL RunningOnMillennium()
  3. {
  4. OSVERSIONINFO VersionInfo;
  5. static BOOL bRet = -2;
  6. if (bRet == -2)
  7. {
  8. bRet = FALSE;
  9. VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  10. if (GetVersionEx(&VersionInfo))
  11. {
  12. if (VersionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
  13. {
  14. bRet = ((VersionInfo.dwMajorVersion == 4) && (VersionInfo.dwMinorVersion == 90));
  15. }
  16. }
  17. }
  18. return bRet;
  19. }
  20. BOOL ConvertHexStringToIntA( CHAR *pszHexNum , int *piNum )
  21. {
  22. int n=0L;
  23. CHAR *psz=pszHexNum;
  24. for(n=0 ; ; psz=CharNextA(psz))
  25. {
  26. if( (*psz>='0') && (*psz<='9') )
  27. n = 0x10 * n + *psz - '0';
  28. else
  29. {
  30. CHAR ch = *psz;
  31. int n2;
  32. if(ch >= 'a')
  33. ch -= 'a' - 'A';
  34. n2 = ch - 'A' + 0xA;
  35. if (n2 >= 0xA && n2 <= 0xF)
  36. n = 0x10 * n + n2;
  37. else
  38. break;
  39. }
  40. }
  41. /*
  42. * Update results
  43. */
  44. *piNum = n;
  45. return (psz != pszHexNum);
  46. }
  47. typedef struct {
  48. WORD wLang;
  49. BOOL fFoundLang;
  50. LPCTSTR lpszType;
  51. } ENUMLANGDATA;
  52. BOOL CALLBACK EnumResLangProc(HINSTANCE hinst, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIdLang, LPARAM lparam)
  53. {
  54. ENUMLANGDATA *pel = (ENUMLANGDATA *)lparam;
  55. BOOL fContinue = TRUE;
  56. if (lpszType == pel->lpszType)
  57. {
  58. if (pel->wLang == PRIMARYLANGID(wIdLang))
  59. {
  60. pel->wLang = wIdLang;
  61. pel->fFoundLang = TRUE;
  62. fContinue = FALSE;
  63. }
  64. }
  65. return fContinue; // continue until we get langs...
  66. }
  67. BOOL GetResourceLanguage(HINSTANCE hinst, LPCTSTR lpszType, LPCTSTR lpszName, WORD wLang)
  68. {
  69. ENUMLANGDATA el;
  70. el.wLang = wLang;
  71. el.fFoundLang = FALSE;
  72. el.lpszType = lpszType;
  73. EnumResourceLanguages(hinst, lpszType, lpszName, EnumResLangProc, (LPARAM)&el);
  74. return el.fFoundLang;
  75. }
  76. BOOL IsBiDiLocalizedBinary(HINSTANCE hinst, LPCTSTR lpszType, LPCTSTR lpszName)
  77. {
  78. static BOOL bRet = -2;
  79. if(bRet == -2)
  80. {
  81. bRet = FALSE;
  82. if(GetResourceLanguage(hinst,lpszType, lpszName, LANG_ARABIC)
  83. || GetResourceLanguage(hinst, lpszType, lpszName, LANG_HEBREW))
  84. {
  85. bRet = TRUE;
  86. }
  87. }
  88. return bRet;
  89. }
  90. BOOL RunningOnWin95BiDiLoc()
  91. {
  92. OSVERSIONINFO VersionInfo;
  93. static BOOL bRet = -2;
  94. HKEY hKey;
  95. DWORD dwType;
  96. CHAR szResourceLocale[12];
  97. DWORD dwSize = sizeof(szResourceLocale)/sizeof(CHAR);
  98. LONG lRes;
  99. int iLCID=0L;
  100. if (bRet == -2)
  101. {
  102. bRet = FALSE;
  103. VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  104. if (GetVersionEx(&VersionInfo))
  105. {
  106. if ((VersionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
  107. && (VersionInfo.dwMajorVersion == 4)
  108. && (VersionInfo.dwMinorVersion < 10)
  109. && (GetSystemMetrics(SM_MIDEASTENABLED))) // Anything before Win98.
  110. {
  111. if( RegOpenKeyExA( HKEY_CURRENT_USER ,
  112. "Control Panel\\Desktop\\ResourceLocale" ,
  113. 0,
  114. KEY_READ, &hKey) == ERROR_SUCCESS)
  115. {
  116. lRes = RegQueryValueExA( hKey , "" , 0 , &dwType , (LPBYTE) szResourceLocale , &dwSize );
  117. RegCloseKey(hKey);
  118. if(ERROR_SUCCESS != lRes)
  119. {
  120. return bRet;
  121. }
  122. if( ConvertHexStringToIntA( szResourceLocale , &iLCID ) )
  123. {
  124. iLCID = PRIMARYLANGID(LANGIDFROMLCID(iLCID));
  125. if( (LANG_ARABIC == iLCID) || (LANG_HEBREW == iLCID) )
  126. {
  127. bRet = TRUE;
  128. }
  129. }
  130. }
  131. }
  132. }
  133. }
  134. return bRet;
  135. }