FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Update for cWinversion()
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Update for cWinversion()
Posted: Sun Dec 11, 2016 05:51 PM
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 (fw): Select all Collapse
<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 (fw): Select all Collapse
.....
   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/library/windows/desktop/ms724834(v=vs.85).aspx
Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Update for cWinversion()
Posted: Mon Dec 12, 2016 11:34 AM

many thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Update for cWinversion()
Posted: Fri May 19, 2017 02:35 PM
Should be correct:

Code (fw): Select all Collapse
   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"........
Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Update for cWinversion()
Posted: Fri Sep 15, 2017 05:28 PM

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

Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Update for cWinversion()
Posted: Sat Sep 16, 2017 09:26 AM
Rick, this is my manifest-file named gun32.exe.manifest. gun32.exe is always the name of the app.

Code (fw): Select all Collapse
<?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>
Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 90
Joined: Wed Nov 07, 2007 08:56 AM
Re: Update for cWinversion()
Posted: Wed Nov 29, 2017 09:21 AM
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 (fw): Select all Collapse
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/library/windows/desktop/ms724834(v=vs.85).aspx

Continue the discussion