added host.windows_version

This commit is contained in:
Liam Devine 2011-03-12 17:42:49 +00:00
parent a8d274d397
commit c68dd29153
3 changed files with 48 additions and 0 deletions

View File

@ -15,5 +15,50 @@ int windows_is_64bit_running_under_wow(struct lua_State* l)
int is_wow = 0;
#endif
lua_pushboolean(l,is_wow);
return 1;
}
int windows_version(struct lua_State* l)
{
#if PLATFORM_WINDOWS == 1
OSVERSIONINFO info = OSVERSIONINFO{0};
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&info);
if( info.dwMajorVersion == 5 && info.dwMinorVersion == 0 )
lua_pushliteral(l,"Windows2000");
else if (info.dwMajorVersion == 5 && info.dwMinorVersion == 1 )
lua_pushliteral(l,"WindowsXP");
else if( info.dwMajorVersion == 5 && info.dwMinorVersion == 2 )
{
if ( OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
&& SYSTEM_INFO.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
lua_pushliteral(l,"WindowsXPProfessionalx64)"
else if(OSVERSIONINFOEX.wSuiteMask & VER_SUITE_WH_SERVER)
lua_pushliteral(l,"WindowsHomeServer");
else if( GetSystemMetrics(SM_SERVERR2) == 0)
lua_pushliteral(l,"WindowsServer2003");
else
lua_pushliteral(l,"WindowsServer2003R2")
}
else if( info.dwMajorVersion == 6 && info.dwMinorVersion == 0 )
{
if( OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION )
lua_pushliteral(l,"WindowsVista");
else
lua_pushliteral(l,"WindowsServer2008");
}
else if ( info.dwMajorVersion == 6 && info.dwMinorVersion == 1 )
{
if (OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION)
lua_pushliteral(l,"WindowsServer2008R2");
else lua_pushliteral(l,"Windows7");
}
else
lua_pushliteral(l,"unknown windows version");
#else
lua_pushliteral(l,"host is not windows");
#endif
return 1;
}

View File

@ -59,6 +59,7 @@ static const luaL_Reg string_functions[] = {
static const luaL_Reg host_functions[] =
{
{ "windows_is_64bit_running_under_wow", windows_is_64bit_running_under_wow },
{ "windows_version",windows_version},
{ NULL, NULL }
};

View File

@ -68,4 +68,6 @@ int os_rmdir(lua_State* L);
int os_uuid(lua_State* L);
int string_endswith(lua_State* L);
int windows_is_64bit_running_under_wow(struct lua_State* l);
int windows_version(struct lua_State* l);