Patch level : 10.0 270

Files correlati     : xvaga.dll
Ricompilazione Demo : [ ]
Commento            :
Migliorato riconoscimento sistema operativo


git-svn-id: svn://10.65.10.50/trunk@18600 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2009-03-24 15:48:30 +00:00
parent 187f2cdfae
commit ffc20a7df8
4 changed files with 143 additions and 126 deletions

View File

@ -39,8 +39,6 @@
///////////////////////////////////////////////////////////////////////////////
// private routines
static LONG GetNextNameValue(HKEY key, LPCTSTR subkey, LPTSTR szName, LPTSTR szData);
static BOOL GetWinVer(LPTSTR lpszVersion, int nVersionSize, int *nVersion);
///////////////////////////////////////////////////////////////////////////////
// defines used by GetWinVer()
@ -224,7 +222,7 @@ BOOL GetFontFile(LPCTSTR lpszFontName,
return bResult;
}
BOOL GetFontsFolder(LPTSTR lpszFontPath, int nFontPathSize)
bool GetFontsFolder(LPTSTR lpszFontPath, int nFontPathSize)
{
_ASSERTE(nFontPathSize >= _MAX_PATH);
*lpszFontPath = '\0';
@ -600,105 +598,106 @@ CE 3
//
///////////////////////////////////////////////////////////////////////////////
// GetWinVer
static BOOL GetWinVer(LPTSTR lpszVersion, int nVersionSize, int *pnVersion)
bool GetWinVer(LPTSTR lpszVersion, int nVersionSize, int *pnVersion)
{
_tcsncpy(lpszVersion, WUNKNOWNSTR, nVersionSize-1);
*pnVersion = WUNKNOWN;
int nVersion = WUNKNOWN;
LPCTSTR cp = WUNKNOWNSTR;
OSVERSIONINFO osinfo; memset(&osinfo, 0, sizeof(osinfo));
osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (!::GetVersionEx(&osinfo))
return FALSE;
if (::GetVersionEx(&osinfo))
{
DWORD dwPlatformId = osinfo.dwPlatformId;
DWORD dwMinorVersion = osinfo.dwMinorVersion;
DWORD dwMajorVersion = osinfo.dwMajorVersion;
DWORD dwBuildNumber = osinfo.dwBuildNumber & 0xFFFF; // Win 95 needs this
TRACE(_T("%d: %d.%d.%d\n"), dwPlatformId, dwMajorVersion, dwMinorVersion, dwBuildNumber);
DWORD dwPlatformId = osinfo.dwPlatformId;
DWORD dwMinorVersion = osinfo.dwMinorVersion;
DWORD dwMajorVersion = osinfo.dwMajorVersion;
DWORD dwBuildNumber = osinfo.dwBuildNumber & 0xFFFF; // Win 95 needs this
TRACE(_T("%d: %d.%d.%d\n"), dwPlatformId, dwMajorVersion, dwMinorVersion, dwBuildNumber);
if ((dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && (dwMajorVersion == 4))
{
if ((dwMinorVersion < 10) && (dwBuildNumber == 950))
{
cp = W95STR;
nVersion = W95;
}
else if ((dwMinorVersion < 10) &&
((dwBuildNumber > 950) && (dwBuildNumber <= 1080)))
{
cp = W95SP1STR;
nVersion = W95SP1;
}
else if ((dwMinorVersion < 10) && (dwBuildNumber > 1080))
{
cp = W95OSR2STR;
nVersion = W95OSR2;
}
else if ((dwMinorVersion == 10) && (dwBuildNumber == 1998))
{
cp = W98STR;
nVersion = W98;
}
else if ((dwMinorVersion == 10) &&
((dwBuildNumber > 1998) && (dwBuildNumber < 2183)))
{
cp = W98SP1STR;
nVersion = W98SP1;
}
else if ((dwMinorVersion == 10) && (dwBuildNumber >= 2183))
{
cp = W98SESTR;
nVersion = W98SE;
}
else if (dwMinorVersion == 90)
{
cp = WMESTR;
nVersion = WME;
}
}
else if (dwPlatformId == VER_PLATFORM_WIN32_NT)
{
if (dwMajorVersion == 3)
{
cp = WNT351STR;
nVersion = WNT351;
}
else if (dwMajorVersion == 4)
{
cp = WNT4STR;
nVersion = WNT4;
}
else if (dwMajorVersion == 5)
{
switch (dwMinorVersion)
{
case 0: cp = W2KSTR; nVersion = W2K; break;
case 1: cp = WXPSTR; nVersion = WXP; break;
case 2:
default: cp = W2003STR; nVersion = W2003; break;
}
}
else if (dwMajorVersion == 6)
{
cp = WVISTASTR;
nVersion = WVISTA;
// TBI: Windows 2008 Server
}
else if (dwMajorVersion >= 7)
{
cp = W7STR;
nVersion = W7;
}
}
else if (dwPlatformId == VER_PLATFORM_WIN32_CE)
{
cp = WCESTR;
nVersion = WCE;
}
}
LPCTSTR cp = WUNKNOWNSTR;
if ((dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && (dwMajorVersion == 4))
{
if ((dwMinorVersion < 10) && (dwBuildNumber == 950))
{
cp = W95STR;
*pnVersion = W95;
}
else if ((dwMinorVersion < 10) &&
((dwBuildNumber > 950) && (dwBuildNumber <= 1080)))
{
cp = W95SP1STR;
*pnVersion = W95SP1;
}
else if ((dwMinorVersion < 10) && (dwBuildNumber > 1080))
{
cp = W95OSR2STR;
*pnVersion = W95OSR2;
}
else if ((dwMinorVersion == 10) && (dwBuildNumber == 1998))
{
cp = W98STR;
*pnVersion = W98;
}
else if ((dwMinorVersion == 10) &&
((dwBuildNumber > 1998) && (dwBuildNumber < 2183)))
{
cp = W98SP1STR;
*pnVersion = W98SP1;
}
else if ((dwMinorVersion == 10) && (dwBuildNumber >= 2183))
{
cp = W98SESTR;
*pnVersion = W98SE;
}
else if (dwMinorVersion == 90)
{
cp = WMESTR;
*pnVersion = WME;
}
}
else if (dwPlatformId == VER_PLATFORM_WIN32_NT)
{
if (dwMajorVersion == 3)
{
cp = WNT351STR;
*pnVersion = WNT351;
}
else if (dwMajorVersion == 4)
{
cp = WNT4STR;
*pnVersion = WNT4;
}
else if (dwMajorVersion == 5)
{
switch (dwMinorVersion)
{
case 0: cp = W2KSTR; *pnVersion = W2K; break;
case 1: cp = WXPSTR; *pnVersion = WXP; break;
case 2:
default: cp = W2003STR; *pnVersion = W2003; break;
}
}
else if (dwMajorVersion == 6)
{
cp = WVISTASTR;
*pnVersion = WVISTA;
// TBI: Windows 2008 Server
}
else if (dwMajorVersion >= 7)
{
cp = W7STR;
*pnVersion = W7;
}
}
else if (dwPlatformId == VER_PLATFORM_WIN32_CE)
{
cp = WCESTR;
*pnVersion = WCE;
}
if (lpszVersion != NULL && nVersionSize > 0)
_tcsncpy(lpszVersion, cp, nVersionSize-1);
if (pnVersion != NULL)
*pnVersion = nVersion;
_tcsncpy(lpszVersion, cp, nVersionSize-1);
return TRUE;
return nVersion == WUNKNOWN;
}

View File

@ -33,6 +33,7 @@ BOOL GetFontFile(LPCTSTR lpszFontName,
BOOL GetFontProperties(LPCTSTR lpszFilePath,
LPFONT_PROPERTIES lpFontProps);
BOOL GetFontsFolder(LPTSTR lpszFontPath, int nFontPathSize);
bool GetFontsFolder(LPTSTR lpszFontPath, int nFontPathSize);
bool GetWinVer(LPTSTR lpszVersion, int nVersionSize, int *nVersion);
#endif //XFONT_H

View File

@ -26,6 +26,7 @@
#ifdef WIN32
#include "oswin32.h"
#include "XFont.h"
#else
#include <errno.h>
#include <unistd.h>
@ -1587,9 +1588,7 @@ void xvt_dwin_draw_dotted_rect(WINDOW win, RCT *rctp)
brush.color = dct.back_color;
brush.pat = PAT_HOLLOW;
xvt_dwin_set_cbrush(win, &brush);
xvt_dwin_draw_rect(win, rctp);
xvt_dwin_set_draw_ctools(win, &dct);
}
@ -3939,34 +3938,49 @@ unsigned long xvt_sys_get_free_memory_kb()
int xvt_sys_get_os_version()
{
int os = 0;
int major, minor;
switch (::wxGetOsVersion(&major, &minor))
{
#ifdef WIN32
case wxWIN95:
os = minor == 0 ? XVT_WS_WIN_95 : XVT_WS_WIN_98; break;
case wxWINDOWS_NT:
os = XVT_WS_WIN_NT;
if (OsWin32_IsWindowsServer())
os = XVT_WS_WIN_SERVER;
break;
#else
case wxGTK:
os = XVT_WS_LINUX; break;
#endif
default:
break;
int nVersion = 0;
::GetWinVer(NULL, 0, &nVersion);
switch (nVersion)
{
case 1:
case 2:
case 3: os = XVT_WS_WIN_95; break;
case 4:
case 5:
case 6: os = XVT_WS_WIN_98; break;
case 7: os = XVT_WS_WIN_ME; break;
case 101:
case 102: os = XVT_WS_WIN_NT; break;
case 103: os = XVT_WS_WIN_2000; break;
case 104: os = XVT_WS_WIN_XP; break;
case 105: os = XVT_WS_WIN_2003; break;
case 106: os = XVT_WS_WIN_VISTA; break;
case 107: os = XVT_WS_WIN_2008; break;
case 108: os = XVT_WS_WIN_7; break;
default : os = XVT_WS_WIN_XP; break;
}
#else
os = XVT_WS_LINUX;
#endif
return os;
}
int xvt_sys_get_version(char* os_version, char* ptk_version, int maxsize)
{
const int version = xvt_sys_get_os_version();
if (os_version && maxsize >= 8)
{
#ifdef WIN32
if (version > XVT_WS_WIN_XP) // wxWidgets non sa descrivere i moderni sistemi Microsoft
::GetWinVer(os_version, maxsize, NULL);
else
#endif
wxStrncpy(os_version, wxGetOsDescription(), maxsize);
}
if (ptk_version && maxsize >= 8)
wxStrncpy(ptk_version, wxVERSION_STRING, maxsize);
return xvt_sys_get_os_version();
return version;
}
void xvt_sys_sleep(unsigned long msec)
@ -4762,3 +4776,4 @@ BOOLEAN statbar_destroy(WINDOW win)
return pStatusBar != NULL;
}

View File

@ -9,15 +9,17 @@
#define XVT_OS XVT_OS_LINUX
#endif
#define XVT_WS_LINUX 301
#define XVT_WS_WIN_95 401
#define XVT_WS_WIN_98 402
#define XVT_WS_WIN_ME 403
#define XVT_WS_WIN_NT 411
#define XVT_WS_WIN_2000 412
#define XVT_WS_WIN_XP 413
#define XVT_WS_WIN_SERVER 414
#define XVT_WS_WIN_VISTA 415
#define XVT_WS_LINUX 107
#define XVT_WS_WIN_95 301
#define XVT_WS_WIN_98 302
#define XVT_WS_WIN_ME 303
#define XVT_WS_WIN_NT 304
#define XVT_WS_WIN_2000 305
#define XVT_WS_WIN_XP 306
#define XVT_WS_WIN_2003 307
#define XVT_WS_WIN_VISTA 308
#define XVT_WS_WIN_2008 309
#define XVT_WS_WIN_7 310
#define XVT_WS_UNKNOWN 0
#define MACWS 100 /* Apple Macintosh */