#define VER_PLATFORM_WIN32s 0
#define VER_PLATFORM_WIN32_WINDOWS 1
#define VER_PLATFORM_WIN32_NT 2
function cWinVersion()
local aVersion := GetVersion()
local cVersion := ""
do case
case aVersion[ 4 ] == VER_PLATFORM_WIN32_NT
if aVersion[ 1 ] == 6
if aVersion[ 2 ] == 0
cVersion = "Vista"
elseif aVersion[ 2 ] == 1
if aVersion[ 3 ] == 7601
cVersion = "Server 2008"
else
cVersion = "7"
endif
elseif aVersion[ 2 ] == 2
if IsWindows10()
cVersion = "10"
else
cVersion = "8"
endif
endif
endif
if aVersion[ 1 ] == 5
if aVersion[ 2 ] == 2
cVersion = "Server 2003"
elseif aVersion[ 2 ] == 1
cVersion = "XP"
elseif aVersion[ 2 ] == 0
cVersion = "2000"
endif
endif
if aVersion[ 1 ] <= 4
cVersion = "NT"
endif
case aVersion[ 4 ] == VER_PLATFORM_WIN32_WINDOWS
if aVersion[ 1 ] == 4
if aVersion[ 2 ] == 90
cVersion = "ME"
elseif aVersion[ 2 ] == 10
cVersion = "98"
elseif aVersion[ 2 ] == 0
cVersion = "95"
endif
endif
endcase
cVersion += IF( IsWin64(), " 64 ", " 32 " ) + "Bits"
return cVersion
Antonio Linares wrote:why not ?
// Detecting the Windows version
#include "FiveWin.ch"
function Main()
MsgInfo( Windows() )
return nil
#pragma BEGINDUMP
#include <Windows.h>
#include <hbapi.h>
HB_FUNC( WINDOWS )
{
OSVERSIONINFOEX vi;
SYSTEM_INFO si;
vi.dwOSVersionInfoSize = sizeof( OSVERSIONINFOEX );
GetVersionEx( ( LPOSVERSIONINFO ) &vi );
GetSystemInfo( &si );
if( vi.dwMajorVersion == 10 && vi.dwMinorVersion == 0 )
if( vi.wProductType == VER_NT_WORKSTATION )
hb_retc( "Windows 10" );
else
hb_retc( "Windows Server 2016" );
if( vi.dwMajorVersion == 6 && vi.dwMinorVersion == 3 )
if( vi.wProductType == VER_NT_WORKSTATION )
hb_retc( "Windows 8.1" );
else
hb_retc( "Windows Server 2012" );
if( vi.dwMajorVersion == 6 && vi.dwMinorVersion == 2 )
if( vi.wProductType == VER_NT_WORKSTATION )
hb_retc( "Windows 8" );
else
hb_retc( "Windows Server 2012 R2" );
if( vi.dwMajorVersion == 6 && vi.dwMinorVersion == 1 )
if( vi.wProductType == VER_NT_WORKSTATION )
hb_retc( "Windows 7" );
else
hb_retc( "Windows Server 2008 R2" );
if( vi.dwMajorVersion == 6 && vi.dwMinorVersion == 0 )
if( vi.wProductType == VER_NT_WORKSTATION )
hb_retc( "Windows Vista" );
else
hb_retc( "Windows Server 2008" );
if( vi.dwMajorVersion == 5 && vi.dwMinorVersion == 2 )
if( GetSystemMetrics( SM_SERVERR2 ) != 0 )
hb_retc( "Windows Server 2003 R2" );
else if( vi.wSuiteMask & VER_SUITE_WH_SERVER )
hb_retc( "Windows Server 2003" );
else if( vi.wProductType == VER_NT_WORKSTATION &&
( si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ) )
hb_retc( "Windows XP Professional x64 Edition" );
if( vi.dwMajorVersion == 5 && vi.dwMinorVersion == 1 )
hb_retc( "Windows XP" );
if( vi.dwMajorVersion == 5 && vi.dwMinorVersion == 1 )
hb_retc( "Windows 2000" );
}
#pragma ENDDUMP
* For applications that have been manifested for Windows 8.1 or Windows 10. Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2). To manifest your applications for Windows 8.1 or Windows 10, refer to Targeting your application for Windows.
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity
type="win32"
name="Contoso.ExampleApplication.ExampleBinary"
version="1.2.3.4"
processorArchitecture="x86"
/>
<description>Contoso Example Application</description>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
</application>
</compatibility>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<!--
UAC settings:
- app should run at same integrity level as calling process
- app does not need to manipulate windows belonging to
higher-integrity-level processes
-->
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"
/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
if( vi.dwMajorVersion == 5 && vi.dwMinorVersion == 0 )
hb_retc( "Windows 2000" );
// Detecting the Windows version
#include "FiveWin.ch"
function Main()
MsgInfo( Windows() )
return nil
#pragma BEGINDUMP
#include <Windows.h>
#include <hbapi.h>
HB_FUNC( WINDOWS )
{
OSVERSIONINFOEX vi;
SYSTEM_INFO si;
vi.dwOSVersionInfoSize = sizeof( OSVERSIONINFOEX );
GetVersionEx( ( LPOSVERSIONINFO ) &vi );
GetSystemInfo( &si );
if( vi.dwMajorVersion == 10 && vi.dwMinorVersion == 0 )
if( vi.wProductType == VER_NT_WORKSTATION )
hb_retc( "Windows 10" );
else
hb_retc( "Windows Server 2016" );
if( vi.dwMajorVersion == 6 && vi.dwMinorVersion == 3 )
if( vi.wProductType == VER_NT_WORKSTATION )
hb_retc( "Windows 8.1" );
else
hb_retc( "Windows Server 2012" );
if( vi.dwMajorVersion == 6 && vi.dwMinorVersion == 2 )
if( vi.wProductType == VER_NT_WORKSTATION )
hb_retc( "Windows 8" );
else
hb_retc( "Windows Server 2012 R2" );
if( vi.dwMajorVersion == 6 && vi.dwMinorVersion == 1 )
if( vi.wProductType == VER_NT_WORKSTATION )
hb_retc( "Windows 7" );
else
hb_retc( "Windows Server 2008 R2" );
if( vi.dwMajorVersion == 6 && vi.dwMinorVersion == 0 )
if( vi.wProductType == VER_NT_WORKSTATION )
hb_retc( "Windows Vista" );
else
hb_retc( "Windows Server 2008" );
if( vi.dwMajorVersion == 5 && vi.dwMinorVersion == 2 )
if( GetSystemMetrics( SM_SERVERR2 ) != 0 )
hb_retc( "Windows Server 2003 R2" );
else if( vi.wSuiteMask & VER_SUITE_WH_SERVER )
hb_retc( "Windows Server 2003" );
else if( vi.wProductType == VER_NT_WORKSTATION &&
( si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ) )
hb_retc( "Windows XP Professional x64 Edition" );
if( vi.dwMajorVersion == 5 && vi.dwMinorVersion == 1 )
hb_retc( "Windows XP" );
if( vi.dwMajorVersion == 5 && vi.dwMinorVersion == 0 )
hb_retc( "Windows 2000" );
}
#pragma ENDDUMP
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 87 guests