diff options
author | Liam Devine <dmail00@gmail.com> | 2011-03-12 20:42:49 +0300 |
---|---|---|
committer | Liam Devine <dmail00@gmail.com> | 2011-03-12 20:42:49 +0300 |
commit | fd2d5d9461fc03b65d8c77069aba21812fdfdaed (patch) | |
tree | a28bf56c46d092a9146dfb6a5480826a133f3da7 /src | |
parent | f8471ad4fa35364d9367520a650c0e642718c099 (diff) |
added host.windows_version
Diffstat (limited to 'src')
-rwxr-xr-x | src/host/host.c | 45 | ||||
-rwxr-xr-x | src/host/premake.c | 1 | ||||
-rwxr-xr-x | src/host/premake.h | 2 |
3 files changed, 48 insertions, 0 deletions
diff --git a/src/host/host.c b/src/host/host.c index c245506..cbdc6a4 100755 --- a/src/host/host.c +++ b/src/host/host.c @@ -16,4 +16,49 @@ int windows_is_64bit_running_under_wow(struct lua_State* l) #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;
}
\ No newline at end of file diff --git a/src/host/premake.c b/src/host/premake.c index 802b6f1..1adceaa 100755 --- a/src/host/premake.c +++ b/src/host/premake.c @@ -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 } }; diff --git a/src/host/premake.h b/src/host/premake.h index 59ccb0c..6967ae2 100755 --- a/src/host/premake.h +++ b/src/host/premake.h @@ -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); + |