Windows 10 version
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
Windows 10 version
How can we detect windows 10 version without mistake ?
Which method is uded
will cWinVersion() return 10 ?
if we use TINFO := OS_VERSIONINFO()
TINFO[1] = 6 .AND. TINFO[2] = 4 // windows 10 ? version 6.4 ?
thanks fo reply
Richard
Which method is uded
will cWinVersion() return 10 ?
if we use TINFO := OS_VERSIONINFO()
TINFO[1] = 6 .AND. TINFO[2] = 4 // windows 10 ? version 6.4 ?
thanks fo reply
Richard
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Windows 10 version
Richard,
I just tested it on Windows 10 and cWinVersion() is not working fine for Windows 10.
cWinversion() is based on Windows API GetVersion() and these are the results that I get for GetVersion()
This is the code for FWH GetVersion():
I don't know how to identify Windows 10 from those values. And vi.szCSDVersion is empty.
We may need to google for a solution
I just tested it on Windows 10 and cWinVersion() is not working fine for Windows 10.
cWinversion() is based on Windows API GetVersion() and these are the results that I get for GetVersion()
This is the code for FWH GetVersion():
Code: Select all
OSVERSIONINFO vi;
vi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
GetVersionEx( &vi );
hb_reta( 5 );
#ifdef __XPP__
#define hb_storc( x, y, z ) STORC( x, params, y, z )
#define hb_stornl( x, y, z ) STORNL( x, params, y, z )
#endif
hb_storvnl( (long) vi.dwMajorVersion, -1, 1 );
hb_storvnl( (long) vi.dwMinorVersion, -1, 2 );
hb_storvnl( (long) vi.dwBuildNumber, -1, 3 );
hb_storvnl( (long) vi.dwPlatformId, -1, 4 );
hb_storvc( (char*) vi.szCSDVersion, -1, 5 );
We may need to google for a solution
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Windows 10 version
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
Applications not manifested for Windows 8.1 or Windows 10 Insider Preview will return the Windows 8 OS version value (6.2). Once an application is manifested for a given operating system version, GetVersionEx will always return the version that the application is manifested for in future releases
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Windows 10 version
By the comments it seems as the developers are not very happy with Microsoft as they broke compatibility with previous code regarding GetVersionEx():
https://msdn.microsoft.com/en-us/librar ... 02074.aspx
Anyhow here there is a good workaround:
https://msdn.microsoft.com/en-us/librar ... 02074.aspx
Anyhow here there is a good workaround:
I just checked it and see what it shows:HKLM\software\microsoft\Windows NT\CurrentVersion
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Windows 10 version
I have implemented a new function IsWindows10() but I don't know why it is not working fine:
So function cWinVersion() could be implemented this way:
Any hints why the above function is not properly working ?
Code: Select all
#define HKEY_LOCAL_MACHINE 2147483650 // 0x80000002
function IsWindows10()
local oReg := TReg32():New( HKEY_LOCAL_MACHINE,;
"SOFTWARE\Microsoft\Windows NT",;
.f. )
local cCurrentVersion := oReg:Get( "CurrentVersion" )
oReg:Close()
// MsgInfo( cCurrentVersion )
return cCurrentVersion == "6.3"
Code: Select all
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
cVersion = "7"
elseif aVersion[ 2 ] == 2
if IsWindows10()
cVersion = "10"
else
cVersion = "8"
endif
endif
endif
...
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Windows 10 version
Solved
Code: Select all
#define HKEY_LOCAL_MACHINE 2147483650 // 0x80000002
function IsWindows10()
local oReg := TReg32():New( HKEY_LOCAL_MACHINE,;
"SOFTWARE\Microsoft\Windows NT\CurrentVersion",;
.f. )
local cCurrentVersion := oReg:Get( "CurrentVersion" )
oReg:Close()
// MsgInfo( cCurrentVersion )
return cCurrentVersion == "6.3"
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
Re: Windows 10 version
Antonio
Thanks for your work,
6.3 is the windows version code for windows 8
Are you running a real windows 10 version ?
From what i read at MSDN
BOOL WINAPI IsWindows10OrGreater(void);
#include <VersionHelpers.h>
…
if (!IsWindows10OrGreater())
{
MessageBox(NULL, "You need at least Windows 10.", "Version Not Supported", MB_OK);
}
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
Tim can you test on your windows 10 version ?
the test is
TINFO := OS_VERSIONINFO()
msginfo("TINFO[1] " + cvaltochar(TINFO[1]) + CRLF + "TINFO[2] " + cvaltochar(TINFO[2])) // i think it will return 6 and 4
Thanks for help
Thanks for your work,
6.3 is the windows version code for windows 8
Are you running a real windows 10 version ?
From what i read at MSDN
BOOL WINAPI IsWindows10OrGreater(void);
#include <VersionHelpers.h>
…
if (!IsWindows10OrGreater())
{
MessageBox(NULL, "You need at least Windows 10.", "Version Not Supported", MB_OK);
}
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
Tim can you test on your windows 10 version ?
the test is
TINFO := OS_VERSIONINFO()
msginfo("TINFO[1] " + cvaltochar(TINFO[1]) + CRLF + "TINFO[2] " + cvaltochar(TINFO[2])) // i think it will return 6 and 4
Thanks for help
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Windows 10 version
Richard,
I am running Windows 10 build 10130
The screenshots I posted were taken with Windows 10 running natively
I am running Windows 10 build 10130
The screenshots I posted were taken with Windows 10 running natively
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Windows 10 version
Richard,
Tested on Windows 10, thats why we have to use the workaround that I posted and it is working fine here
Tested on Windows 10, thats why we have to use the workaround that I posted and it is working fine here
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
Re: Windows 10 version
Antonio
I am still puzzled, all those values are messed
6.2 is windows 8
6.3 is windows 8.1
so if you force 6.3 in iswin10() , windows 8.1 will return windows 10
i think the most reliable way is to test the product name
below is a copy of my registry in windows 8.1
http://www.logicielspro/rcc/temp/windows8.png
I am still puzzled, all those values are messed
6.2 is windows 8
6.3 is windows 8.1
so if you force 6.3 in iswin10() , windows 8.1 will return windows 10
i think the most reliable way is to test the product name
below is a copy of my registry in windows 8.1
http://www.logicielspro/rcc/temp/windows8.png
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Windows 10 version
Richard,
The image is not available. Please send it to me by email, thanksbelow is a copy of my registry in windows 8.1
http://www.logicielspro/rcc/temp/windows8.png
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Windows 10 version
Richard,
This function seems to be ok
This function seems to be ok
Code: Select all
#define HKEY_LOCAL_MACHINE 2147483650 // 0x80000002
function IsWindows10()
local oReg := TReg32():New( HKEY_LOCAL_MACHINE,;
"SOFTWARE\Microsoft\Windows NT\CurrentVersion",;
.f. )
local cProductName := oReg:Get( "ProductName" )
oReg:Close()
return "Windows 10" $ cProductName