
#ifndef DKUTIL_OS_HPP
#define DKUTIL_OS_HPP

#include <dkutil/config.hpp>
#include <dkutil_c/dkcOS.h>

namespace dkutil{


inline bool isOSWin95_First_or_SP1(OSVERSIONINFO *os){

	if(os->dwPlatformId == VER_PLATFORM_WIN32_WINDOWS){
		if(os->dwMajorVersion == 4){
			if(os->dwMinorVersion == 0){
				if(os->dwBuildNumber <= 950){
					return true;
				}
			}
		}
	}
	return false;
}

inline bool isOSWin95_OSR2_or_21(OSVERSIONINFO *os){
	if(os->dwPlatformId == VER_PLATFORM_WIN32_WINDOWS){
		if(os->dwMajorVersion == 4){
			if(os->dwMinorVersion == 0){
				if( 950 < os->dwBuildNumber && os->dwBuildNumber <= 1111){
					return true;
				}
			}
		}
	}
	return false;
}

inline bool isOSWin95_OSR_25(OSVERSIONINFO *os){
	if(os->dwPlatformId == VER_PLATFORM_WIN32_WINDOWS){
		if(os->dwMajorVersion == 4){
			if(os->dwMinorVersion == 0){
				if(1111 < os->dwBuildNumber && os->dwBuildNumber <= 1212){
					return true;
				}
			}
		}
	}
	return false;
}

inline bool isOSWin95(){
	/*	OSVERSIONINFO os;
	os.dwOSVersionInfoSize=sizeof(os);

	 
	if(GetVersionEx(&os)==0){
		throw std::runtime_error("GetVersionEx Error");
	}*/
	return (dkcGetOSVersion() == enuWindows95);
}
inline bool isOSWinNT40(){
	return (dkcGetOSVersion() ==enuWindowsNT4_0);
}




///WindowsOSがNT系かどうか
inline bool isOSNT(){
	int r=dkcGetOSVersion();
	if(r != enuWindows3_1 && 
		r != enuWindows95 && 
		r != enuWindowsMe && 
		r != enuWindows98)
	{
		return true;
	}
	return false;
}

///OSが9x系かどうか
inline bool isOS9x(){
	return (!isOSNT());
}

/*!
dkcGetOSVersion関数を内部で使ってそれをもとにWindowsの種類を文字列にする。<br>
@param [out] copybuff 文字列バッファのアドレスを渡します
@param [in] buffsize copybuffのサイズをバイト単位で入れます。
@return true = succeeded / false = failed
*/
///Windowsの種類を文字列にする。
inline bool GetOSName(char *copybuff,size_t buffsize){
	int temp=dkcGetOSVersion();
	if(temp < 0)
		return false;
	static char *table[8]={
		"Windows3.1",
		"WindowsNT3.51",
		"WindowsNT4.0",
		"Windows95",
		"Windows98",
		"Windows2000",
		"WindowsMe",
		"WindowsXP"
	};
	if(copybuff != NULL && buffsize !=0){
		_snprintf(copybuff,buffsize,table[temp]);
	}else{
		return false;
	}
	return true;
}


}//end of dkutil namespace



#endif
