Remove the need for OSVersion code.

This commit is contained in:
Emmet Young 2015-02-16 17:19:11 +11:00
parent 6a3836d40f
commit fb6e9aa4fe
7 changed files with 1 additions and 449 deletions

View File

@ -145,10 +145,6 @@
RelativePath="MemTest.cpp"
>
</File>
<File
RelativePath="osversion.cpp"
>
</File>
<File
RelativePath="path.cpp"
>
@ -218,10 +214,6 @@
RelativePath="MemTest.h"
>
</File>
<File
RelativePath="osversion.h"
>
</File>
<File
RelativePath="path.h"
>

View File

@ -42,7 +42,6 @@
<ClCompile Include="Log Class.cpp" />
<ClCompile Include="md5.cpp" />
<ClCompile Include="MemTest.cpp" />
<ClCompile Include="osversion.cpp" />
<ClCompile Include="path.cpp" />
<ClCompile Include="registry.cpp" />
<ClCompile Include="std string.cpp" />
@ -59,7 +58,6 @@
<ClInclude Include="Log Class.h" />
<ClInclude Include="md5.h" />
<ClInclude Include="MemTest.h" />
<ClInclude Include="osversion.h" />
<ClInclude Include="path.h" />
<ClInclude Include="registry.h" />
<ClInclude Include="Smart Pointer.h" />

View File

@ -26,9 +26,6 @@
<ClCompile Include="MemTest.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="osversion.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="path.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -67,9 +64,6 @@
<ClInclude Include="MemTest.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="osversion.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="path.h">
<Filter>Header Files</Filter>
</ClInclude>

View File

@ -62,11 +62,6 @@ bool CFile::Open(LPCTSTR lpszFileName, ULONG nOpenFlags)
_ASSERTE(false);
}
COSVersion osver;
WORD ostype = osver.GetOSType();
BOOL is_NT =((ostype & OS_WINNT) != 0);
// map share mode
ULONG dwShareMode = 0;
@ -94,7 +89,7 @@ bool CFile::Open(LPCTSTR lpszFileName, ULONG nOpenFlags)
dwCreateFlag = OPEN_EXISTING;
// attempt file creation
HANDLE hFile = ::CreateFile(lpszFileName, dwAccess, dwShareMode, is_NT ? &sa : NULL,
HANDLE hFile = ::CreateFile(lpszFileName, dwAccess, dwShareMode, &sa,
dwCreateFlag, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{ //#define ERROR_PATH_NOT_FOUND 3L

View File

@ -1,306 +0,0 @@
//---------------------------------------------------------------------------
// Copyright (C) 1998, Interscope Ltd. All rights reserved.
// Reproduction or distribution of this program, or any portion of it,
// is permitted only if this header is kept as it is.
// For more information, contact:
//
// Interscope Ltd., 5 Culturii St., 5th Floor, 4800 Baia Mare, RO
// Phone/Fax: +40-62-215023
// E-mail: office@interscope.ro
//
// $Author: Levente Farkas $
// $Date: 5/12/98 11:50p $
// $Modtime: 4/30/98 8:22a $
// $Revision: 23 $
// $Archive: /Interscope/Thebe/InstallMaster/OSVersion.cpp $
// $Workfile: OSVersion.cpp $
//---------------------------------------------------------------
// 4 more details about API calls in this module, see
// Knowledge Base Atricle Q113998 and
// Knowledge Base Atricle Q114470 on
// Microsoft Development Library (October 1995)
//Ads - This is very out of date!
// Rewrote the O/S detection in the constructor 15/3/2002
#include "stdafx.h"
#pragma comment(lib, "version.lib")
//--- Some types and consts -----------------------------------
#define WNNC_NET_MULTINET 0x8000
#define WNNC_SUBNET_WINWORKGROUP 0x0004
#define WNNC_NET_TYPE 0x0002
typedef WORD (WINAPI *NETCAPFUNC)(int);
//-------------------------------------------------------------
// Task : Constructs and OS version class and extracts all the
// version information necessary
//-------------------------------------------------------------
COSVersion::COSVersion():
m_nOSType(OS_UNKNOWN),
m_nWinType(WIN_UNKNOWN),
m_dwVersion(GetVersion())
{
#if defined(__WIN32__) || defined(_WIN32) // 32-bit platform
osvi.dwOSVersionInfoSize = sizeof(osvi);
GetVersionEx(&osvi);
//Determine which versions of the O/S we are running
if (osvi.dwPlatformId == VER_PLATFORM_WIN32s) //Win32s on windows 3.1
{
m_nWinType = WIN_32S;
// Determine if Win 3.X or WFW
if(IsWindows4Workgroups(METHOD_FILEVERSION))
m_nOSType = OS_WFW;
else if(IsWindows4Workgroups(METHOD_MULTINET))
m_nOSType = OS_WFW;
else
m_nOSType = OS_WIN3X;
}
else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) //Win 95, 98 or ME
{
m_nWinType = WIN_32C;
// Determine if Win95 or Win98 or WinMe
if(osvi.dwMinorVersion == 0)
m_nOSType = OS_WIN95;
else if (osvi.dwMinorVersion == 10)
m_nOSType = OS_WIN98;
else if (osvi.dwMinorVersion == 90)
m_nOSType = OS_WINME;
else
m_nOSType = OS_UNKNOWN;
}
else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) //Win NT 3.51, 4.0, 2000, XP or .Net Server
{
m_nWinType = WIN_32;
//Determine which version
if (osvi.dwMajorVersion == 3)
{
m_nOSType = OS_WINNT351;
}
else if (osvi.dwMajorVersion == 4)
{
m_nOSType = OS_WINNT40;
}
if (osvi.dwMajorVersion == 5)
{
if (osvi.dwMinorVersion == 0)
{
m_nOSType = OS_WIN2000;
}
else
{
m_nOSType = OS_WINXP | OS_WINNET;
}
}
else
{
m_nOSType = OS_WINNT; //Future proof
}
}
/*
else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_CE) //Windows CE
{
m_nOSType = OS_WINCE;
}
*/
/* Original code
// Test 4 NT/NTS/NTAS by the highest bit of the version
if(m_dwVersion & 0x80000000)
{
// This is not NT
// Check major version number 2 distinguish between
// WIN32s (Win 3.X) and WIN32c (Win 95)
if(LOBYTE(LOWORD(m_dwVersion)) <= 3)
{
m_nWinType =WIN_32S;
// Determine if Win 3.X or WFW
if(IsWindows4Workgroups(METHOD_FILEVERSION))
m_nOSType =OS_WFW;
else if(IsWindows4Workgroups(METHOD_MULTINET))
m_nOSType =OS_WFW;
else
m_nOSType =OS_WIN3X;
}
else
{
m_nWinType =WIN_32C;
// Determine if Win95 or Win98 or WinMe
// Note: We consider Win98 from beta 2 up (4.10.1650)
ASSERT(osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
if(osvi.dwMinorVersion == 0)
m_nOSType =OS_WIN95;
else if (osvi.dwMinorVersion == 10)
m_nOSType =OS_WIN98;
else if (osvi.dwMinorVersion == 90)
m_nOSType =OS_WINME;
}
}
else
{
// Must be NTWS, NTS or NTAS
// Check the registry 2 distinguish between them
HKEY hKey;
BYTE szValue[128];
DWORD dwSize =sizeof(szValue);
RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SYSTEM\\CurrentControlSet\\Control\\ProductOptions"),
0,KEY_READ,&hKey);
RegQueryValueEx(hKey,_T("ProductType"),0,NULL,szValue,&dwSize);
RegCloseKey(hKey);
if(!STRICMP((TCHAR *)&szValue[0],_T("WinNT")))
// WinNT (Windows NT Workstation)
m_nOSType =OS_WINNTWS;
else if(!STRICMP((TCHAR *)&szValue[0],_T("ServerNT")))
// ServerNT (Windows NT Server)
m_nOSType =OS_WINNTS;
else
// LanmanNT (Windows NT Advanced Server)
m_nOSType =OS_WINNTAS;
m_nWinType =WIN_32;
}
*/
#else // 16-bit platform
// For 16-bit code, use GetWinFlags 2 find out if running on the
// Windows on Windows layer of NT/NTAS
if(GetWinFlags() & 0x4000)
m_nOSType =OS_WINNTWS;
else
{
// Check version number 2 distinguish between Win 3.X and Win 95
if((LOBYTE(LOWORD(dwVersion)) > 3) ||
(HIBYTE(LOWORD(dwVersion)) > 50))
// Windows 95
m_nOSType =OS_WIN95;
else
{
// Determine if Win 3.X or WFW
if(IsWindows4Workgroups(MEHOD_FILEVERSION))
m_nOSType =OS_WFW;
else if(IsWindows4Workgroups(METHOD_MULTINET))
m_nOSType =OS_WFW;
else
m_nOSType =OS_WIN3X;
}
}
m_nWinType =WIN_16;
#endif
}
//-------------------------------------------------------------
// Pre : Check method
// Task : Checks if running on Windows 4 Workgroups
//-------------------------------------------------------------
BOOL COSVersion::IsWindows4Workgroups(unsigned short usMethod) {
WORD wNetType;
DWORD dwVerSize, dwVerHandle;
HANDLE hMem;
VS_VERSION FAR *lpVerInfo;
BOOL bWfW =FALSE;
if(usMethod == METHOD_MULTINET)
{
// Use the method that checks 4 multinet driver
HINSTANCE hLib =LoadLibrary((LPTSTR)"USER.EXE");
if((WORD)hLib >= (WORD)HINSTANCE_ERROR)
{
// Check if library loaded OK
//NETCAPFUNC lpWNetGetCaps =(NETCAPFUNC)GetProcAddress(hLib,_T("WNetGetCaps"));
NETCAPFUNC lpWNetGetCaps =(NETCAPFUNC)GetProcAddress(hLib,"WNetGetCaps");
if(lpWNetGetCaps != NULL)
{
wNetType =(*lpWNetGetCaps)(WNNC_NET_TYPE);
if((wNetType & WNNC_NET_MULTINET) &&
(LOBYTE(wNetType) & WNNC_SUBNET_WINWORKGROUP))
// Yes, it is Windows 4 Workgroups
bWfW =TRUE;
}
if(hLib)
FreeLibrary(hLib);
}
}
else
{
// Use the method that checks the fileversion of USER.EXE
// Allocate memory 4 the file info struct
dwVerSize =GetFileVersionInfoSize(_T("USER.EXE"),&dwVerHandle);
hMem =GlobalAlloc(GMEM_MOVEABLE,dwVerSize);
if(hMem != NULL)
{
lpVerInfo =(VS_VERSION FAR *)GlobalLock(hMem);
// Get the file version
// in Win32, the dwVerHandle is zero, ignored
if(GetFileVersionInfo(_T("USER.EXE"),dwVerHandle,dwVerSize,lpVerInfo))
if((HIWORD(lpVerInfo->vffInfo.dwProductVersionMS) == 3) &&
(LOWORD(lpVerInfo->vffInfo.dwProductVersionMS) == 11))
// Yes, it is Windows 4 Workgroups
bWfW =TRUE;
GlobalUnlock(hMem);
GlobalFree(hMem);
}
}
return bWfW;
}
//-------------------------------------------------------------
// Task : Get OS major version number
//-------------------------------------------------------------
DWORD COSVersion::GetMajorVersion() const
{
#if defined(__WIN32__) || defined(_WIN32)
return osvi.dwMajorVersion;
#else
return (DWORD)(LOBYTE(LOWORD(dwVersion)));
#endif
}
//-------------------------------------------------------------
// Task : Get OS minor version number
//-------------------------------------------------------------
DWORD COSVersion::GetMinorVersion() const
{
#if defined(__WIN32__) || defined(_WIN32)
return osvi.dwMinorVersion;
#else
return (DWORD)(HIBYTE(LOWORD(dwVersion)));
#endif
}
#if defined(__WIN32__) || defined(_WIN32)
//-------------------------------------------------------------
// Task : Get the build number of the OS
//-------------------------------------------------------------
DWORD COSVersion::GetBuildNumber() const
{
return (m_nOSType & OS_WINNT) ? osvi.dwBuildNumber : LOWORD(osvi.dwBuildNumber);
}
#endif
#if defined(__WIN32__) || defined(_WIN32)
//-------------------------------------------------------------
// Task : Get the special version data (string got from GetVersionEX)
//-------------------------------------------------------------
LPCTSTR COSVersion::GetSpecialVersion() const
{
return osvi.szCSDVersion;
}
#endif

View File

@ -1,120 +0,0 @@
//---------------------------------------------------------------------------
// Copyright (C) 1998, Interscope Ltd. All rights reserved.
// Reproduction or distribution of this program, or any portion of it,
// is permitted only if this header is kept as it is.
// For more information, contact:
//
// Interscope Ltd., 5 Culturii St., 5th Floor, 4800 Baia Mare, RO
// Phone/Fax: +40-62-215023
// E-mail: office@interscope.ro
//
// $Author: Levente Farkas $
// $Date: 5/13/98 12:03a $
// $Modtime: 4/27/98 6:50a $
// $Revision: 17 $
// $Archive: /Interscope/Thebe/InstallMaster/OSVersion.Hpp $
// $Workfile: OSVersion.Hpp $
//-----------------------------------------------------------------------------
#ifndef __OperatingSystemVersion_Hpp__
#define __OperatingSystemVersion_Hpp__
// Define the following symbol if compiling using precompiled headers through
// header file StdAfx.H
// #define __STDAFX__
//
// Define the following symbol if used in a MFC project
#if !defined(__WIN32__) && !defined(_WIN32)
#ifndef STRICT
#define STRICT
#endif
#endif // __WIN32__
#if defined(__WIN32__) || defined(_WIN32)
#include <WinVer.H>
#else
#include <Ver.H>
#endif
//--- Extended OS and Win32 (tm) version types --------------------------------
#define OS_UNKNOWN 0x0000
#define OS_WIN3X 0x0001
#define OS_WFW 0x0002
#define OS_WIN95 0x0004
#define OS_WIN98 0x0008
#define OS_WINME 0x0010
#define OS_WINNT351 0x0020
#define OS_WINNT40 0x0040
#define OS_WINNTWS 0x0080 // Workstation
#define OS_WINNTS 0x0100 // Server
#define OS_WINNTAS 0x0200 // Advanced server (only if older than 4.0)
#define OS_WIN2000 0x0400
#define OS_WINXP 0x0800
#define OS_WINNET 0x1000
#define OS_WINNT (OS_WINNT351 | OS_WINNTWS | OS_WINNTS | OS_WINNTAS | OS_WIN2000 | OS_WINXP | OS_WINNET)
#define OS_WINCE 0x2000
#define WIN_UNKNOWN 0x0000
#define WIN_16 0x0100
#define WIN_32 0x0200
#define WIN_32S 0x0400
#define WIN_32C 0x0800
//--- Windows 4 Workgroups detection methods --------------------------------
#define METHOD_MULTINET 1
#define METHOD_FILEVERSION 2
//--- OS version checker class ----------------------------------------------
class COSVersion
{
// Type(s)
protected:
struct VS_VERSION
{
WORD wTotLen;
WORD wValLen;
char szSig[16];
VS_FIXEDFILEINFO vffInfo;
};
// Data members
private:
WORD m_nOSType;
WORD m_nWinType;
DWORD m_dwVersion;
#if defined(__WIN32__) || defined(_WIN32)
OSVERSIONINFO osvi;
#endif
// Construction
public:
COSVersion();
// Implementation
public:
WORD GetOSType() const { return m_nOSType; } // Returns one of the OS_ constants
WORD GetWindowsType() const { return m_nWinType; } // Returns one of the WIN_ constants
DWORD GetMajorVersion() const;
DWORD GetMinorVersion() const;
#if defined(__WIN32__) || defined(_WIN32)
DWORD GetBuildNumber() const;
LPCTSTR GetSpecialVersion() const;
#endif
// Helper(s)
private:
BOOL IsWindows4Workgroups(unsigned short usMethod);
};
#endif

View File

@ -10,7 +10,6 @@
#include "CriticalSection.h"
#include "File Class.h"
#include "Ini File Class.h"
#include "osversion.h"
#include "registry.h"
#include "path.h"
#include "Log Class.h"