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

View File

@ -33,6 +33,7 @@ BOOL GetFontFile(LPCTSTR lpszFontName,
BOOL GetFontProperties(LPCTSTR lpszFilePath, BOOL GetFontProperties(LPCTSTR lpszFilePath,
LPFONT_PROPERTIES lpFontProps); 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 #endif //XFONT_H

View File

@ -26,6 +26,7 @@
#ifdef WIN32 #ifdef WIN32
#include "oswin32.h" #include "oswin32.h"
#include "XFont.h"
#else #else
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
@ -1587,9 +1588,7 @@ void xvt_dwin_draw_dotted_rect(WINDOW win, RCT *rctp)
brush.color = dct.back_color; brush.color = dct.back_color;
brush.pat = PAT_HOLLOW; brush.pat = PAT_HOLLOW;
xvt_dwin_set_cbrush(win, &brush); xvt_dwin_set_cbrush(win, &brush);
xvt_dwin_draw_rect(win, rctp); xvt_dwin_draw_rect(win, rctp);
xvt_dwin_set_draw_ctools(win, &dct); 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 xvt_sys_get_os_version()
{ {
int os = 0; int os = 0;
int major, minor;
switch (::wxGetOsVersion(&major, &minor))
{
#ifdef WIN32 #ifdef WIN32
case wxWIN95: int nVersion = 0;
os = minor == 0 ? XVT_WS_WIN_95 : XVT_WS_WIN_98; break; ::GetWinVer(NULL, 0, &nVersion);
case wxWINDOWS_NT: switch (nVersion)
os = XVT_WS_WIN_NT; {
if (OsWin32_IsWindowsServer()) case 1:
os = XVT_WS_WIN_SERVER; case 2:
break; case 3: os = XVT_WS_WIN_95; break;
#else case 4:
case wxGTK: case 5:
os = XVT_WS_LINUX; break; case 6: os = XVT_WS_WIN_98; break;
#endif case 7: os = XVT_WS_WIN_ME; break;
default: case 101:
break; 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; return os;
} }
int xvt_sys_get_version(char* os_version, char* ptk_version, int maxsize) 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) 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); wxStrncpy(os_version, wxGetOsDescription(), maxsize);
}
if (ptk_version && maxsize >= 8) if (ptk_version && maxsize >= 8)
wxStrncpy(ptk_version, wxVERSION_STRING, maxsize); wxStrncpy(ptk_version, wxVERSION_STRING, maxsize);
return xvt_sys_get_os_version(); return version;
} }
void xvt_sys_sleep(unsigned long msec) void xvt_sys_sleep(unsigned long msec)
@ -4762,3 +4776,4 @@ BOOLEAN statbar_destroy(WINDOW win)
return pStatusBar != NULL; return pStatusBar != NULL;
} }

View File

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