Update for cWinversion()

Update for cWinversion()

Postby byte-one » Sun Dec 11, 2016 5: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: Select all  Expand view  RUN
<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  Expand view  RUN
.....
   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
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Update for cWinversion()

Postby Antonio Linares » Mon Dec 12, 2016 11:34 am

many thanks
regards, saludos

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

Re: Update for cWinversion()

Postby byte-one » Fri May 19, 2017 2:35 pm

Should be correct:

Code: Select all  Expand view  RUN
  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
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Update for cWinversion()

Postby Rick Lipkin » Fri Sep 15, 2017 5: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
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Update for cWinversion()

Postby byte-one » Sat Sep 16, 2017 9:26 am

Rick, this is my manifest-file named gun32.exe.manifest. gun32.exe is always the name of the app.

Code: Select all  Expand view  RUN
<?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
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Update for cWinversion()

Postby Patrizio » Wed Nov 29, 2017 9: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: Select all  Expand view  RUN

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
Patrizio
 
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 20 guests