Windows 10 version

Windows 10 version

Postby Richard Chidiak » Mon Jun 08, 2015 1:17 pm

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
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Windows 10 version

Postby Antonio Linares » Mon Jun 08, 2015 3:11 pm

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  Expand view  RUN
     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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Windows 10 version

Postby Antonio Linares » Mon Jun 08, 2015 3:16 pm

https://msdn.microsoft.com/en-us/library/windows/desktop/ms724451%28v=vs.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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Windows 10 version

Postby Antonio Linares » Mon Jun 08, 2015 3:25 pm

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/library/windows/desktop/dn302074.aspx

Anyhow here there is a good workaround:

HKLM\software\microsoft\Windows NT\CurrentVersion


I just checked it and see what it shows:

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Windows 10 version

Postby Antonio Linares » Mon Jun 08, 2015 3:38 pm

I have implemented a new function IsWindows10() but I don't know why it is not working fine:

Code: Select all  Expand view  RUN
#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  Expand view  RUN
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 ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Windows 10 version

Postby Antonio Linares » Mon Jun 08, 2015 3:50 pm

Solved :-)

Code: Select all  Expand view  RUN
#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"
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Windows 10 version

Postby Antonio Linares » Mon Jun 08, 2015 3:53 pm

Working fine :-)

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Windows 10 version

Postby Richard Chidiak » Mon Jun 08, 2015 5:32 pm

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
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Windows 10 version

Postby Antonio Linares » Mon Jun 08, 2015 6:27 pm

Richard,

I am running Windows 10 build 10130

The screenshots I posted were taken with Windows 10 running natively
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Windows 10 version

Postby Antonio Linares » Mon Jun 08, 2015 6:32 pm

Richard,

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

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Windows 10 version

Postby Richard Chidiak » Tue Jun 09, 2015 8:24 am

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
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Windows 10 version

Postby Antonio Linares » Tue Jun 09, 2015 10:03 am

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Windows 10 version

Postby Antonio Linares » Tue Jun 09, 2015 11:36 am

Richard,

This function seems to be ok :-)

Code: Select all  Expand view  RUN
#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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: MaxP and 51 guests