Page 1 of 1

Windows 10 version

Posted: Mon Jun 08, 2015 1:17 pm
by Richard Chidiak
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

Re: Windows 10 version

Posted: Mon Jun 08, 2015 3:11 pm
by Antonio Linares
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()

Image

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 );
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

Re: Windows 10 version

Posted: Mon Jun 08, 2015 3:16 pm
by Antonio Linares
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

Re: Windows 10 version

Posted: Mon Jun 08, 2015 3:25 pm
by Antonio Linares
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:
HKLM\software\microsoft\Windows NT\CurrentVersion
I just checked it and see what it shows:

Image

Re: Windows 10 version

Posted: Mon Jun 08, 2015 3:38 pm
by Antonio Linares
I have implemented a new function IsWindows10() but I don't know why it is not working fine:

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"
 
So function cWinVersion() could be implemented this way:

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  

...
 
Any hints why the above function is not properly working ?

Re: Windows 10 version

Posted: Mon Jun 08, 2015 3:50 pm
by Antonio Linares
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"
 

Re: Windows 10 version

Posted: Mon Jun 08, 2015 3:53 pm
by Antonio Linares
Working fine :-)

Image

Re: Windows 10 version

Posted: Mon Jun 08, 2015 5:32 pm
by Richard Chidiak
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

Re: Windows 10 version

Posted: Mon Jun 08, 2015 6:27 pm
by Antonio Linares
Richard,

I am running Windows 10 build 10130

The screenshots I posted were taken with Windows 10 running natively

Re: Windows 10 version

Posted: Mon Jun 08, 2015 6:32 pm
by Antonio Linares
Richard,

Tested on Windows 10, thats why we have to use the workaround that I posted and it is working fine here

Image

Re: Windows 10 version

Posted: Tue Jun 09, 2015 8:24 am
by Richard Chidiak
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

Re: Windows 10 version

Posted: Tue Jun 09, 2015 10:03 am
by Antonio Linares
Richard,
below is a copy of my registry in windows 8.1
http://www.logicielspro/rcc/temp/windows8.png
The image is not available. Please send it to me by email, thanks

Re: Windows 10 version

Posted: Tue Jun 09, 2015 11:36 am
by Antonio Linares
Richard,

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