Merge pull request #88 from death-droid/PathOSVersionCleanup
Path os version cleanup
This commit is contained in:
commit
d033a4f2b8
|
@ -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"
|
||||
>
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -35,41 +35,8 @@ class CPath
|
|||
public:
|
||||
|
||||
enum DIR_CURRENT_DIRECTORY { CURRENT_DIRECTORY = 1 };
|
||||
enum DIR_WINDOWS_DIRECTORY { WINDOWS_DIRECTORY = 2 };
|
||||
enum DIR_SYSTEM_DIRECTORY { SYSTEM_DIRECTORY = 3 };
|
||||
enum DIR_SYSTEM32_DIRECTORY { SYSTEM32_DIRECTORY = 4 };
|
||||
enum DIR_SYSTEM_DRIVER_DIRECTORY { SYSTEM_DRIVER_DIRECTORY = 5 };
|
||||
enum DIR_SYSTEM_DRIVE_ROOT_DIRECTORY { SYSTEM_DRIVE_ROOT_DIRECTORY = 6 };
|
||||
enum DIR_MODULE_DIRECTORY { MODULE_DIRECTORY = 7 };
|
||||
enum DIR_MODULE_FILE { MODULE_FILE = 8 };
|
||||
|
||||
enum SpecialDirectoryType
|
||||
{
|
||||
TEMP_DIRECTORY,
|
||||
PROGRAM_FILES_DIRECTORY,
|
||||
COMMON_FILES_DIRECTORY,
|
||||
ACCESSORIES_DIRECTORY,
|
||||
MEDIA_DIRECTORY,
|
||||
DEVICE_DIRECTORY,
|
||||
USER_DESKTOP_DIRECTORY,
|
||||
USER_FAVORITES_DIRECTORY,
|
||||
USER_FONTS_DIRECTORY,
|
||||
USER_NETHOOD_DIRECTORY,
|
||||
USER_DOCUMENTS_DIRECTORY,
|
||||
USER_RECENT_DIRECTORY,
|
||||
USER_SENDTO_DIRECTORY,
|
||||
USER_TEMPLATES_DIRECTORY,
|
||||
USER_RECYCLE_DIRECTORY,
|
||||
USER_APPLICATION_DATA_DIRECTORY,
|
||||
USER_STARTMENU_DIRECTORY,
|
||||
USER_STARTMENU_STARTUP_DIRECTORY,
|
||||
USER_STARTMENU_PROGRAMS_DIRECTORY,
|
||||
COMMON_DESKTOP_DIRECTORY,
|
||||
COMMON_STARTMENU_DIRECTORY,
|
||||
COMMON_STARTMENU_STARTUP_DIRECTORY,
|
||||
COMMON_STARTMENU_PROGRAMS_DIRECTORY,
|
||||
LAST_SPECIAL
|
||||
};
|
||||
enum DIR_MODULE_DIRECTORY { MODULE_DIRECTORY = 2 };
|
||||
enum DIR_MODULE_FILE { MODULE_FILE = 3 };
|
||||
|
||||
enum { _A_ALLFILES = 0xFFFF }; /* Search Include all files */
|
||||
|
||||
|
@ -93,16 +60,8 @@ public:
|
|||
CPath(const stdstr& strPath);
|
||||
CPath(const stdstr& strPath, LPCTSTR NameExten);
|
||||
CPath(const stdstr& strPath, const stdstr& NameExten);
|
||||
CPath(SpecialDirectoryType sdt);
|
||||
CPath(SpecialDirectoryType sdt, LPCTSTR NameExten );
|
||||
CPath(SpecialDirectoryType sdt, const stdstr& NameExten );
|
||||
|
||||
|
||||
CPath(DIR_CURRENT_DIRECTORY sdt, LPCTSTR NameExten = NULL);
|
||||
CPath(DIR_WINDOWS_DIRECTORY sdt, LPCTSTR NameExten = NULL);
|
||||
CPath(DIR_SYSTEM_DIRECTORY sdt, LPCTSTR NameExten = NULL );
|
||||
CPath(DIR_SYSTEM32_DIRECTORY sdt, LPCTSTR NameExten = NULL);
|
||||
CPath(DIR_SYSTEM_DRIVER_DIRECTORY sdt, LPCTSTR NameExten = NULL);
|
||||
CPath(DIR_SYSTEM_DRIVE_ROOT_DIRECTORY sdt, LPCTSTR NameExten = NULL);
|
||||
CPath(DIR_MODULE_DIRECTORY sdt, LPCTSTR NameExten = NULL);
|
||||
CPath(DIR_MODULE_FILE sdt);
|
||||
|
||||
|
@ -122,8 +81,6 @@ public:
|
|||
operator stdstr&() { return m_strPath; }
|
||||
|
||||
//Get path components
|
||||
void GetDrive(stdstr& rDrive) const;
|
||||
stdstr GetDrive(void) const;
|
||||
void GetDriveDirectory(stdstr& rDriveDirectory) const;
|
||||
stdstr GetDriveDirectory(void) const;
|
||||
void GetDirectory(stdstr& rDirectory) const;
|
||||
|
@ -137,18 +94,14 @@ public:
|
|||
void GetCurrentDirectory(stdstr& rDrive) const;
|
||||
stdstr GetCurrentDirectory(void) const;
|
||||
void GetFullyQualified(stdstr& rFullyQualified) const;
|
||||
void GetFullyQualifiedShort(stdstr& rFullyQualifiedShort) const;
|
||||
void GetComponents(stdstr* pDrive =NULL,
|
||||
stdstr* pDirectory =NULL,
|
||||
stdstr* pName =NULL,
|
||||
stdstr* pExtension =NULL) const;
|
||||
void GetAsInternetPath(stdstr& Directory) const;
|
||||
|
||||
//Get other state
|
||||
BOOL IsEmpty() const { return m_strPath.empty(); }
|
||||
BOOL IsRelative() const;
|
||||
BOOL IsWild() const;
|
||||
BOOL IsValid() const; // Checks lexical correctness only
|
||||
|
||||
//Set path components
|
||||
void SetDrive(TCHAR chDrive);
|
||||
|
@ -168,94 +121,28 @@ public:
|
|||
|
||||
//Set whole path
|
||||
void Empty() { m_strPath.erase(); }
|
||||
void SpecialDirectory(SpecialDirectoryType sdt);
|
||||
void MakeRoot();
|
||||
void CurrentDirectory();
|
||||
void WindowsDirectory();
|
||||
void SystemDirectory();
|
||||
void SystemDriveRootDirectory();
|
||||
void TempDirectory();
|
||||
void Module();
|
||||
void Module(HINSTANCE hInstance);
|
||||
void ModuleDirectory();
|
||||
void ModuleDirectory(HINSTANCE hInstance);
|
||||
void ProgramFilesDirectory(); // C:\Program Files
|
||||
void CommonFilesDirectory(); // C:\Program Files\Common Files
|
||||
void AccessoriesDirectory(); // C:\Program Files\Accessories
|
||||
void MediaDirectory(); // C:\Windows\Media
|
||||
void DeviceDirectory(); // C:\Windows\Inf
|
||||
void UserDesktopDirectory();
|
||||
void UserFavoritesDirectory();
|
||||
void UserFontsDirectory();
|
||||
void UserNetworkNeighbourhoodDirectory();
|
||||
void UserDocumentsDirectory();
|
||||
void UserRecentDirectory();
|
||||
void UserSendToDirectory();
|
||||
void UserTemplatesDirectory();
|
||||
void UserRecycleBinDirectory();
|
||||
void UserApplicationDataDirectory();
|
||||
void UserStartMenuDirectory();
|
||||
void UserStartMenuStartupDirectory();
|
||||
void UserStartMenuProgramsDirectory();
|
||||
void CommonDesktopDirectory();
|
||||
void CommonStartMenuDirectory();
|
||||
void CommonStartMenuStartupDirectory();
|
||||
void CommonStartMenuProgramsDirectory();
|
||||
void WindowsProfile(); // Win.INI
|
||||
void SystemProfile(); // System.INI
|
||||
|
||||
BOOL CreateTempName(LPCTSTR lpcszPrefix);
|
||||
BOOL CreateTempDir(LPCTSTR lpcszPrefix, UINT nRetries =100);
|
||||
BOOL CreateRandomName(BOOL bMustNotExist =TRUE, UINT nRetries =1000);
|
||||
BOOL CreateSimilarName(BOOL bMustNotExist =TRUE, UINT nRetries =1000);
|
||||
|
||||
//Drive Information
|
||||
UINT GetDriveType() const;
|
||||
BOOL IsRemovableDrive() const { return GetDriveType()==DRIVE_REMOVABLE; }
|
||||
BOOL IsCDRomDrive() const { return GetDriveType()==DRIVE_CDROM; }
|
||||
BOOL IsNetworkDrive() const { return GetDriveType()==DRIVE_REMOTE; }
|
||||
BOOL IsRAMDrive() const { return GetDriveType()==DRIVE_RAMDISK; }
|
||||
BOOL IsFixedDrive() const { return GetDriveType()==DRIVE_FIXED; }
|
||||
|
||||
ULONG DriveTotalSpaceBytes() const;
|
||||
ULONG DriveFreeSpaceBytes() const;
|
||||
ULONG GetDriveClusterSize() const;
|
||||
BOOL GetDiskInfo(LPDWORD lpSectorsPerCluster,
|
||||
LPDWORD lpBytesPerSector,
|
||||
LPDWORD lpFreeClusters,
|
||||
LPDWORD lpClusters) const;
|
||||
|
||||
//Directory information
|
||||
BOOL IsDirectory() const;
|
||||
BOOL DirectoryExists() const;
|
||||
BOOL IsDirectoryEmpty() const;
|
||||
|
||||
//File Information
|
||||
BOOL IsFile() const { return !IsDirectory(); }
|
||||
BOOL Exists() const;
|
||||
ULONG GetSize() const;
|
||||
ULONG GetAttributes() const;
|
||||
BOOL GetTime(FILETIME *lpCreated, FILETIME *lpAccessed, FILETIME *lpModified) const;
|
||||
FILETIME GetTimeCreated() const;
|
||||
FILETIME GetTimeLastModified() const;
|
||||
FILETIME GetTimeLastAccessed() const;
|
||||
|
||||
//Directory operations
|
||||
BOOL CreateDirectory(BOOL bCreateIntermediates =TRUE);
|
||||
BOOL RemoveDirectory(BOOL bEvenIfNotEmpty =FALSE);
|
||||
BOOL RemoveDirectoryContent();
|
||||
BOOL ChangeDirectory();
|
||||
|
||||
//File operations
|
||||
BOOL Delete(BOOL bEvenIfReadOnly =TRUE) const;
|
||||
BOOL Rename(LPCTSTR lpszNewPath);
|
||||
BOOL CopyTo(LPCTSTR lpcszTargetFile, BOOL bOverwrite =TRUE);
|
||||
BOOL MoveTo(LPCTSTR lpcszTargetFile, BOOL bOverwrite =TRUE);
|
||||
BOOL SetAttributes(ULONG dwAttributes);
|
||||
BOOL SetTime(const FILETIME *lpCreated, const FILETIME *lpAccessed, const FILETIME *lpModified);
|
||||
BOOL SetTimeCreated(const FILETIME *lpCreated);
|
||||
BOOL SetTimeLastModified(const FILETIME *lpModified);
|
||||
BOOL SetTimeLastAccessed(const FILETIME *lpAccessed);
|
||||
|
||||
//Finders
|
||||
BOOL FindFirst(ULONG dwAttributes =_A_NORMAL);
|
||||
|
@ -267,10 +154,6 @@ public:
|
|||
|
||||
private:
|
||||
BOOL AttributesMatch(ULONG dwTargetAttributes, ULONG dwFileAttributes);
|
||||
BOOL ShellDirectory(int nShellFolderID);
|
||||
BOOL ShellDirectory2(int nShellFolderID);
|
||||
BOOL GetRegistryPath(HKEY hRootKey, LPCTSTR lpcszKeyName, LPCTSTR lpcszValueName, stdstr &strPath);
|
||||
|
||||
|
||||
void cleanPathString(stdstr& rDirectory) const;
|
||||
void StripLeadingChar(stdstr& rText, TCHAR chLeading) const;
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue