⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hxwinver.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: hxwinver.cpp,v 1.11.24.4 2004/07/09 01:48:16 hubbe Exp $ *  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. *  * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks.  You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL.  Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. *  * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. *  * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. *  * Technology Compatibility Kit Test Suite(s) Location: *    http://www.helixcommunity.org/content/tck *  * Contributor(s): *  * ***** END LICENSE BLOCK ***** */#include "hxtypes.h"#ifdef _WINDOWS#include <windows.h>#include <stdlib.h>             // needed for _MAX_PATH#include <string.h>             // needed for strXXX() functions#endif#ifdef _MACINTOSH#include <stdio.h>#include <stdlib.h>#include <string.h>#ifndef _MAC_MACHO#include "OpenTransport.h"#endif//#include "productversion.r"#endif#if defined(HELIX_CONFIG_NOSTATICS)# include "globals/hxglobals.h"#endif#include "hxassert.h"#include "hxwinver.h"#include "dbcs.h"//#include "hlxclib/stdio.h"#ifdef _WIN32#include "hxdllldr.h"#endif#ifdef _UNIX#include <stdlib.h>#ifndef _VXWORKS#include <sys/utsname.h>#endif  // VXWORKS#endif#include "hxstrutl.h"#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILEstatic const char HX_THIS_FILE[] = __FILE__;#endif#ifdef _WINDOWS// Helper function for Win32.#if defined(_WIN32)BOOL IsCoProcessorPresentInWinNT(void);#elseextern "C" int FAR PASCAL Is586( void );#endif#if defined(_WIN32) || defined(_WINDOWS)BOOL ExtractDistributionCode(char* pDistBuffer, HMODULE hModule);#endif#endif //_WINDOWS// Helper functions for macintosh#if defined(_MACINTOSH) || defined(_MAC_UNIX)void    GetMacSystemVersion(UINT16      *major, UINT16  *minor, UINT16  *release);#if !defined(_CARBON) && !defined(_MAC_UNIX)BOOL    IsPPC(void);BOOL    HasFPU(void);BOOL    HasOpenTransport (void);#endif#endif/*** DWORD HXGetWinVer( HXVERSIONINFO *pVersionInfo )**  PARAMETERS:*              pVersionInfo : A pointer to the version info struct to receive the*                             results.  (Can be NULL, in which case our only side*                             effect is our return value).**  DESCRIPTION:*              Gets information on the Windows platform and version we are running on.**  RETURNS:*              A flag indicating the platform we are running on.**              If this is a 16bit build of a Helix module, then*              one of the following values is possible:**                      HX_PLATFORM_WINNT*                      HX_PLATFORM_WIN95*                      HX_PLATFORM_WIN16**              If this is a 32bit build of a Helix module, then*              one of the following values is possible:**                      HX_PLATFORM_WINNT*                      HX_PLATFORM_WIN95*                      HX_PLATFORM_WIN32S**  NOTES:*    The behavior of the GetVersion() API is totally different under*    16bit and 32bit builds. As such we have been forced to implement*    this function differently for each compiler version.**/ULONG32 HXGetWinVer( HXVERSIONINFO* lpVersionInfo ){    HXVERSIONINFO       rVersionInfo;    // Initialize Defaults!    rVersionInfo.dwPlatformId  = HX_PLATFORM_UNKNOWN;    rVersionInfo.dwMachineType = HX_MACHINE_UNKNOWN;    rVersionInfo.wMajorVersion = 0;    rVersionInfo.wMinorVersion = 0;    rVersionInfo.wReleaseVersion = 0;    rVersionInfo.bFPUAvailable = FALSE;#ifdef _WINDOWS ////////// WINDOWS SPECIFIC //////////#ifdef _WIN32    OSVERSIONINFO osVersionInfo;    memset(&osVersionInfo, 0, sizeof(OSVERSIONINFO));    osVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);    GetVersionEx(&osVersionInfo);    rVersionInfo.wMajorVersion = (UINT16)(osVersionInfo.dwMajorVersion);    rVersionInfo.wMinorVersion = (UINT16)(osVersionInfo.dwMinorVersion);    rVersionInfo.wReleaseVersion = (UINT16)(osVersionInfo.dwBuildNumber);    BOOL bIsNT = (osVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);#else    ULONG32 dwVersion = GetVersion();    rVersionInfo.wMajorVersion = (WORD)(LOBYTE( LOWORD( dwVersion ) ));    rVersionInfo.wMinorVersion = (WORD)(HIBYTE( LOWORD( dwVersion ) ));    BOOL bIsNT = ((GetWinFlags() & 0x4000) == 0x4000);#endif    if (bIsNT)    {        // Windows NT        rVersionInfo.dwPlatformId = HX_PLATFORM_WINNT;    }#ifdef _WIN32    // In a 32bit build, we call GetVersionEx:    // Win95 returns MajorVersion 4, MinorVersion 0    // Win98 returns MajorVersion 4, MinorVersion 10    //    else if (rVersionInfo.wMajorVersion < 4)    {        // Win32s        rVersionInfo.dwPlatformId = HX_PLATFORM_WIN32S;    }    else if (rVersionInfo.wMajorVersion == 4)    {        if (rVersionInfo.wMinorVersion < 10)        {            // Win95            rVersionInfo.dwPlatformId = HX_PLATFORM_WIN95;        }        else        {            // Windows 98            rVersionInfo.dwPlatformId = HX_PLATFORM_WIN98;        }    }#else    // In a 16bit build, we call GetVersion:    // Win95 returns MajorVersion 3, MinorVersion 95    // Win98 returns MajorVersion ??, MinorVersion ??    //    else if (rVersionInfo.wMajorVersion == 3)    {        if (rVersionInfo.wMinorVersion < 95)        {            // Win16            rVersionInfo.dwPlatformId = HX_PLATFORM_WIN16;        }        else if (rVersionInfo.wMinorVersion < 98)        {            // Windows 98            rVersionInfo.dwPlatformId = HX_PLATFORM_WIN95;        }        // XXXBJP need to confirm minorVersion > 95 in 16-bit Win98        else         {            // Windows 98            rVersionInfo.dwPlatformId = HX_PLATFORM_WIN98;        }    }#endif    // Don't bother with any of the rest of this code, if no    // struct was passed in!!!!!    if (lpVersionInfo)    {        // Determine processor and FPU capabilities...#if defined(_WIN32)        SYSTEM_INFO     sysInfo;        GetSystemInfo(&sysInfo);        switch (sysInfo.wProcessorArchitecture)        {           case PROCESSOR_ARCHITECTURE_INTEL:           {               rVersionInfo.dwMachineType = HX_MACHINE_UNKNOWN;               // Only Newer versions of NT correctly supports wProcessorLevel.               if       (                   bIsNT                   &&                   (                       (rVersionInfo.wMajorVersion > 3)                       ||                       (rVersionInfo.wMajorVersion == 3 && rVersionInfo.wMinorVersion >= 50)                       )                   )               {                   int nVerGreaterThan486 = (sysInfo.wProcessorLevel - 4);                   if (nVerGreaterThan486 < 0)                   {                       rVersionInfo.dwMachineType = HX_MACHINE_TOOSLOW;                   }                   else if (nVerGreaterThan486 == 0)                   {                       rVersionInfo.dwMachineType = HX_MACHINE_486;                   }                   else if (nVerGreaterThan486 == 1)                   {                       rVersionInfo.dwMachineType = HX_MACHINE_586;                   }                   else if (nVerGreaterThan486 == 2)                   {                       rVersionInfo.dwMachineType = HX_MACHINE_686;                   }                   else                   {                       rVersionInfo.dwMachineType = HX_MACHINE_UNKNOWN;                   }               }               else               {                   // Win95, Win32s, and old versions of NT don't correctly support                   // Processor level, so instead we look at dwProcessorType                   switch (sysInfo.dwProcessorType)                   {                      case PROCESSOR_INTEL_386:      rVersionInfo.dwMachineType = HX_MACHINE_TOOSLOW;  break;                      case PROCESSOR_INTEL_486:      rVersionInfo.dwMachineType = HX_MACHINE_486;      break;                      case PROCESSOR_INTEL_PENTIUM:  rVersionInfo.dwMachineType = HX_MACHINE_586;      break;                      default:                       rVersionInfo.dwMachineType = HX_MACHINE_UNKNOWN;  break;                   }               }           }           break;           case PROCESSOR_ARCHITECTURE_MIPS:           {               rVersionInfo.dwMachineType = HX_MACHINE_MIPS;           }           break;           case PROCESSOR_ARCHITECTURE_ALPHA:           {               rVersionInfo.dwMachineType = HX_MACHINE_ALPHA;           }           break;           case PROCESSOR_ARCHITECTURE_PPC:           {               rVersionInfo.dwMachineType = HX_MACHINE_PPC;           }           break;           default:           {               rVersionInfo.dwMachineType = HX_MACHINE_UNKNOWN;           }           break;        }        rVersionInfo.bFPUAvailable = IsCoProcessorPresentInWinNT();#else        DWORD dwWinFlags = GetWinFlags();        if      (            (dwWinFlags & WF_CPU386)            ||            (dwWinFlags & WF_CPU286)            ||            (dwWinFlags & WF_CPU186)            ||            (dwWinFlags & WF_CPU086)            )        {            rVersionInfo.dwMachineType = HX_MACHINE_TOOSLOW;        }        if (dwWinFlags & WF_CPU486)        {#ifdef _WIN16            //=-=w16.3 Is586() asserts pentium.obj; must be fixed; #ifdefed to TRUE            int nVerGreaterThan486 = TRUE;#else            int nVerGreaterThan486 = Is586();#endif            switch(nVerGreaterThan486)            {               case 0:  rVersionInfo.dwMachineType = HX_MACHINE_486;     break;               case 1:  rVersionInfo.dwMachineType = HX_MACHINE_586;     break;               case 2:  rVersionInfo.dwMachineType = HX_MACHINE_686;     break;               default: rVersionInfo.dwMachineType = HX_MACHINE_UNKNOWN; break;            }        }        if (dwWinFlags & WF_80x87)        {            rVersionInfo.bFPUAvailable = TRUE;        }#endif    }////////// END WINDOWS SPECIFIC //////////////////// START MACINTOSH SPECIFIC CODE//////////#elif defined(_MACINTOSH) || defined(_MAC_UNIX)#if defined(_CARBON) || defined(_MAC_UNIX)    rVersionInfo.dwPlatformId  = HX_PLATFORM_MACOT;    rVersionInfo.dwMachineType = HX_MACHINE_PPC;    rVersionInfo.bFPUAvailable = FALSE;#else    if (HasOpenTransport())        rVersionInfo.dwPlatformId  = HX_PLATFORM_MACOT;    else        rVersionInfo.dwPlatformId  = HX_PLATFORM_MACTCP;    if (IsPPC())        rVersionInfo.dwMachineType = HX_MACHINE_PPC;    else        rVersionInfo.dwMachineType = HX_MACHINE_68K;    rVersionInfo.bFPUAvailable = HasFPU();#endif    GetMacSystemVersion(&rVersionInfo.wMajorVersion,                        &rVersionInfo.wMinorVersion,                        &rVersionInfo.wReleaseVersion);////////// END MACINTOSH SPECIFIC CODE////////////#elif defined(_UNIX)    struct utsname osInfo;   // structure to hold uname info    if (uname(&osInfo) != -1)    {        double nVersionNum = atof(osInfo.release);  // version number        char *pPeriod = NULL;        rVersionInfo.wMajorVersion = (UINT16)nVersionNum;        if (pPeriod = strchr(osInfo.release,'.'))            rVersionInfo.wMinorVersion = atoi(pPeriod+1);        // CODE FOR LINUX#ifdef _LINUX        // These are defaults, they are not 100% correct but they shouldn't be needed        rVersionInfo.dwPlatformId = HX_PLATFORM_LINUX;        rVersionInfo.dwMachineType = HX_MACHINE_586;        // CODE FOR SOLARIS#elif _SOLARIS        // These are defaults, they are not 100% correct but they shouldn't be needed        rVersionInfo.dwPlatformId = HX_PLATFORM_SOLARIS;        rVersionInfo.dwMachineType = HX_MACHINE_SPARC;        // do platform mapping        if (!strcasecmp("SunOS",osInfo.sysname))        {            if (nVersionNum > 5.0)                rVersionInfo.dwPlatformId = HX_PLATFORM_SOLARIS;            else                rVersionInfo.dwPlatformId = HX_PLATFORM_SUNOS;        }        // do machine mapping        if (!strcasecmp("sun4m",osInfo.machine))            rVersionInfo.dwMachineType = HX_MACHINE_SPARC;        // CODE FOR IRIX#elif _IRIX        rVersionInfo.dwPlatformId = HX_PLATFORM_IRIX;        rVersionInfo.dwMachineType = HX_MACHINE_MIPS;        // CODE FOR SUNOS#elif _SUNOS        // These are defaults, they are not 100% correct but they shouldn't be needed        rVersionInfo.dwPlatformId = HX_PLATFORM_SUNOS;        rVersionInfo.dwMachineType = HX_MACHINE_SPARC;        // do platform mapping        if (!strcasecmp("SunOS",osInfo.sysname))        {            if (nVersionNum > 5.0)                rVersionInfo.dwPlatformId = HX_PLATFORM_SOLARIS;            else                rVersionInfo.dwPlatformId = HX_PLATFORM_SUNOS;        }        // do machine mapping        if (!strcasecmp("sun4m",osInfo.machine))            rVersionInfo.dwMachineType = HX_MACHINE_SPARC;#else        rVersionInfo.dwPlatformId = HX_PLATFORM_UNKNOWN;        rVersionInfo.dwMachineType = HX_MACHINE_UNKNOWN;#endif    }    rVersionInfo.bFPUAvailable = TRUE;////////// END UNIX SPECIFIC CODE////////////#elif defined(_SYMBIAN)        rVersionInfo.dwPlatformId  = HX_PLATFORM_SYMBIAN;#ifdef __WINS__        rVersionInfo.dwMachineType = HX_MACHINE_SYMEMULATOR;#else    rVersionInfo.dwMachineType = HX_MACHINE_ARM;#endif    //XXGFW need to not hard code this.    rVersionInfo.wMajorVersion   = 6;    rVersionInfo.wMinorVersion   = 1;    rVersionInfo.wReleaseVersion = 0;    rVersionInfo.bFPUAvailable   = FALSE;    #elif defined(_OPENWAVE)        rVersionInfo.dwPlatformId  = HX_PLATFORM_OPENWAVE;#ifdef _OPENWAVE_SIMULATOR    rVersionInfo.dwMachineType = HX_MACHINE_OWEMULATOR;#else    rVersionInfo.dwMachineType = HX_MACHINE_ARM;#endif    // XXXSAB need to not hard code this.    rVersionInfo.wMajorVersion   = 6;    rVersionInfo.wMinorVersion   = 1;    rVersionInfo.wReleaseVersion = 0;    rVersionInfo.bFPUAvailable   = FALSE;    #else#error Add your platform code here!#endif    if (lpVersionInfo)    {        *lpVersionInfo = rVersionInfo;    }    return( rVersionInfo.dwPlatformId );}/*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -