Page 1 of 1

Update for cWinversion()

Posted: Sun Dec 11, 2016 5:51 pm
by byte-one
This function should be updated!

To become correct build-numbers this should be added to your manifest: (Without this extension from the manifest, always the build-numbers from 8 returned, also on 8.1 and 10)

Code: Select all

<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 Vista -->
           <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> 
            <!-- Windows 7 -->
           <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
           <!-- Windows 8 -->
           <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
       </application> 
    </compatibility>
 
Now i add this to the source from cWinversion:

Code: Select all

.....
   do case
      case aVersion[ 4 ] == VER_PLATFORM_WIN32_NT
           if aVersion[ 1 ] == 10     //if manifest for 10
                   cVersion = "10"
           elseif aVersion[ 1 ] == 8 .and. aVersion[ 2 ] == 3    //if manifest for 8.1
                   cVersion = "8.1"
           elseif 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
.......
 
Informations also on https://msdn.microsoft.com/en-us/librar ... s.85).aspx

Re: Update for cWinversion()

Posted: Mon Dec 12, 2016 11:34 am
by Antonio Linares
many thanks

Re: Update for cWinversion()

Posted: Fri May 19, 2017 2:35 pm
by byte-one
Should be correct:

Code: Select all

   do case
      case aVersion[ 4 ] == VER_PLATFORM_WIN32_NT
           if aVersion[ 1 ] == 10       //if manifest for 10 is present
                   cVersion = "10"
           elseif aVersion[ 1 ] == 6 .and. aVersion[ 2 ] == 3   //if manifest for 8.1 is present  -->>> corrected!
                   cVersion = "8.1"........

Re: Update for cWinversion()

Posted: Fri Sep 15, 2017 5:28 pm
by Rick Lipkin
Günther

I am re-visiting the Windows 10.Manifest file ... I am reviewing your comments ... would you mind posting your complete Windows10.Manifest file please ..

Thanks
Rick Lipkin

Re: Update for cWinversion()

Posted: Sat Sep 16, 2017 9:26 am
by byte-one
Rick, this is my manifest-file named gun32.exe.manifest. gun32.exe is always the name of the app.

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
 <dependency>
   <dependentAssembly>
     <assemblyIdentity
       type="win32"
       name="Microsoft.Windows.Common-Controls"
       version="6.0.0.0"
       publicKeyToken="6595b64144ccf1df"
       language="*"
       processorArchitecture="*"/>
   </dependentAssembly>
 </dependency>
 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
   <security>
     <requestedPrivileges>
       <requestedExecutionLevel
         level="asInvoker"
         uiAccess="false"/>
       </requestedPrivileges>
   </security>
 </trustInfo>
<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 Vista -->
           <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> 
            <!-- Windows 7 -->
           <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
           <!-- Windows 8 -->
           <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
       </application> 
    </compatibility>
</assembly>
 

Re: Update for cWinversion()

Posted: Wed Nov 29, 2017 9:21 am
by Patrizio
Hi to all,

the function cWinVersion() fails with Windows Server series ( Windows Server 2003, 2003 R2, 2008, 2008 R2, 2012, 2012 R2, 2016).

The GetVersion() function return only data from struct OSVERSIONINFO, but the information of Server series are stored in OSVERSIONINFOEX.

If you change the GetVersion() to return an array of 6 elements you can do this

Code: Select all

HB_FUNC( GETVERSION ) //  --> anVersions
{
   #ifndef __FLAT__
      DWORD lInfo = GetVersion();

      hb_reta( 4 );

      hb_storni( LOBYTE( LOWORD( lInfo ) ), -1, 1 );
      hb_storni( HIBYTE( LOWORD( lInfo ) ), -1, 2 );
      hb_storni( HIBYTE( HIWORD( lInfo ) ), -1, 3 );
      hb_storni( LOBYTE( HIWORD( lInfo ) ), -1, 4 );
   #else
      OSVERSIONINFO vi;

      vi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
      GetVersionEx( &vi );

      hb_reta( 6 );

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

OSVERSIONINFOEX vie;
GetVersionEx( ( OSVERSIONINFO * ) &vie );
hb_storvnl( (long) vie.wProductType,  -1, 6 );


   #endif
}

 
And then test in cWinVersion the sixth element like this link

https://msdn.microsoft.com/it-it/librar ... s.85).aspx