Skip to content

Commit

Permalink
2018-02-11 23:40 UTC+0100 Aleksander Czajczynski (hb fki.pl)
Browse files Browse the repository at this point in the history
  * include/hbapi.h
  * src/common/hbver.c
  * src/harbour.def
  * contrib/hbwin/win_osc.c
    * synced Windows version detection code with Viktor's work in 3.4

  * src/main/Makefile
  + src/main/harbour.rc
    * include Windows manifest in standalone compiler - "harbour.exe /build"
      should now correctly report Windows 10. "yourapp.exe //build" plus
      in-app results still depend on manual manifest inclusion within .rc
  • Loading branch information
alcz committed Feb 11, 2018
1 parent d6f7c59 commit 8545d4b
Show file tree
Hide file tree
Showing 7 changed files with 511 additions and 381 deletions.
13 changes: 13 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@
Entries may not always be in chronological/commit order.
See license at the end of file. */

2018-02-11 23:40 UTC+0100 Aleksander Czajczynski (hb fki.pl)
* include/hbapi.h
* src/common/hbver.c
* src/harbour.def
* contrib/hbwin/win_osc.c
* synced Windows version detection code with Viktor's work in 3.4

* src/main/Makefile
+ src/main/harbour.rc
* include Windows manifest in standalone compiler - "harbour.exe /build"
should now correctly report Windows 10. "yourapp.exe //build" plus
in-app results still depend on manual manifest inclusion within .rc

2018-02-11 12:55 UTC+0100 Aleksander Czajczynski (hb fki.pl)
* package/harbour.mft
+ added version manifest to Harbour compiler binaries, which is more
Expand Down
188 changes: 90 additions & 98 deletions contrib/hbwin/win_osc.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* Windows OS version information
*
* Copyright 2014 Viktor Szakats (vszakats.net/harbour)
* Copyright 2004 Peter Rees <[email protected]> Rees Software and Systems Ltd
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -47,174 +48,165 @@
#include "hbwin.h"
#include "hbapiitm.h"

static void getwinver( OSVERSIONINFO * pOSvi )
{
pOSvi->dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
GetVersionEx( pOSvi );
}

HB_FUNC( WIN_OSISNT )
{
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_retl( osvi.dwPlatformId == VER_PLATFORM_WIN32_NT );
hb_retl( hb_iswinnt() != 0 );
}

HB_FUNC( WIN_OSISNT351 )
{
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_retl( osvi.dwPlatformId == VER_PLATFORM_WIN32_NT &&
osvi.dwMajorVersion == 3 && osvi.dwMinorVersion == 51 );
hb_retl( hb_iswinnt() == 3 );
}

HB_FUNC( WIN_OSISNT4 )
{
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_retl( osvi.dwPlatformId == VER_PLATFORM_WIN32_NT &&
osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0 );
hb_retl( hb_iswinnt() == 4 );
}

HB_FUNC( WIN_OSIS2000ORUPPER )
HB_FUNC( WIN_OSIS2000 )
{
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_retl( osvi.dwMajorVersion >= 5 );
hb_retl( hb_iswinver( 5, 0, 0, HB_FALSE ) );
}

HB_FUNC( WIN_OSIS2000 )
HB_FUNC( WIN_OSIS2000ORUPPER )
{
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_retl( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 );
hb_retl( hb_iswin2k() );
}

HB_FUNC( WIN_OSISXP )
{
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_retl( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 );
hb_retl( hb_iswinver( 5, 1, 0, HB_FALSE ) );
}

HB_FUNC( WIN_OSISWINXPORUPPER )
{
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_retl( osvi.dwMajorVersion > 5 || ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion >= 1 ) );
hb_retl( hb_iswinver( 5, 1, 0, HB_TRUE ) );
}

HB_FUNC( WIN_OSIS2003 )
{
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_retl( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 );
hb_retl( hb_iswinver( 5, 2, 0, HB_FALSE ) );
}

HB_FUNC( WIN_OSISVISTA )
{
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_retl( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 );
hb_retl( hb_iswinver( 6, 0, 0, HB_FALSE ) );
}

HB_FUNC( WIN_OSISVISTAORUPPER )
{
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_retl( osvi.dwMajorVersion >= 6 );
hb_retl( hb_iswinvista() );
}

HB_FUNC( WIN_OSIS7 )
{
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_retl( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1 );
hb_retl( hb_iswinver( 6, 1, 0, HB_FALSE ) );
}

HB_FUNC( WIN_OSIS8 )
{
OSVERSIONINFO osvi;
hb_retl( hb_iswinver( 6, 2, 0, HB_FALSE ) );
}

HB_FUNC( WIN_OSIS81 )
{
hb_retl( hb_iswinver( 6, 3, 0, HB_FALSE ) );
}

getwinver( &osvi );
hb_retl( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 2 );
HB_FUNC( WIN_OSIS10 )
{
hb_retl( hb_iswinver( 10, 0, 0, HB_FALSE ) );
}

HB_FUNC( WIN_OSIS9X )
{
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_retl( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS );
hb_retl( hb_iswin9x() );
}

HB_FUNC( WIN_OSIS95 )
{
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_retl( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS &&
osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0 );
hb_retl( hb_iswin9x() == 5 );
}

HB_FUNC( WIN_OSIS98 )
{
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_retl( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS &&
osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10 );
hb_retl( hb_iswin9x() == 8 );
}

HB_FUNC( WIN_OSISME )
{
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_retl( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS &&
osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90 );
hb_retl( hb_iswin9x() == 9 );
}

HB_FUNC( WIN_OSISTSCLIENT )
{
HB_BOOL bResult = HB_FALSE;
OSVERSIONINFO osvi;
/* Only supported on NT 4.0 SP3 & higher */
#ifndef SM_REMOTESESSION
#define SM_REMOTESESSION 0x1000
#endif

getwinver( &osvi );
if( osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 4 )
{
/* Only supported on NT 4.0 SP3 & higher */
#ifndef SM_REMOTESESSION
#define SM_REMOTESESSION 0x1000
#endif
bResult = ( GetSystemMetrics( SM_REMOTESESSION ) != 0 );
}
hb_retl( bResult );
hb_retl( GetSystemMetrics( SM_REMOTESESSION ) != 0 );
}

HB_FUNC( WIN_OSVERSIONINFO )
{
PHB_ITEM pArray = hb_itemArrayNew( 5 );
OSVERSIONINFO osvi;

getwinver( &osvi );
hb_arraySetNL( pArray, 1, osvi.dwMajorVersion );
hb_arraySetNL( pArray, 2, osvi.dwMinorVersion );
if( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
osvi.dwBuildNumber = LOWORD( osvi.dwBuildNumber );
hb_arraySetNL( pArray, 3, osvi.dwBuildNumber );
hb_arraySetNL( pArray, 4, osvi.dwPlatformId );
HB_ARRAYSETSTR( pArray, 5, osvi.szCSDVersion );

int iMajor = 4;
int iMinor = 0;
int pos;

typedef struct
{
int iMajor;
int iMinor;
} HB_ISWINVER;

static const HB_ISWINVER s_vers[] = {
{ 10, 0 },
{ 6, 3 },
{ 6, 2 },
{ 6, 1 },
{ 6, 0 },
{ 5, 2 },
{ 5, 1 },
{ 5, 0 } };

for( pos = 0; pos < ( int ) HB_SIZEOFARRAY( s_vers ); ++pos )
{
if( hb_iswinver( s_vers[ pos ].iMajor, s_vers[ pos ].iMinor, 0, ( pos == 0 ) ) )
{
iMajor = s_vers[ pos ].iMajor;
iMinor = s_vers[ pos ].iMinor;
break;
}
}

hb_arraySetNL( pArray, 1, iMajor );
hb_arraySetNL( pArray, 2, iMinor );
hb_arraySetNL( pArray, 3, 0 );
#if defined( HB_OS_WIN_CE )
hb_arraySetNL( pArray, 4, VER_PLATFORM_WIN32_CE );
#else
hb_arraySetNL( pArray, 4, hb_iswinnt() ? VER_PLATFORM_WIN32_NT : VER_PLATFORM_WIN32_WINDOWS );
#endif
hb_arraySetC( pArray, 5, NULL );

if( hb_iswin2k() )
{
int tmp;

for( tmp = 5; tmp > 0; --tmp )
{
if( hb_iswinsp( tmp, HB_TRUE ) )
{
char szServicePack[ 8 ];
hb_snprintf( szServicePack, sizeof( szServicePack ), "SP%u", tmp );
hb_arraySetC( pArray, 5, szServicePack );
break;
}
}
}

hb_itemReturnRelease( pArray );
}
9 changes: 6 additions & 3 deletions include/hbapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1203,16 +1203,19 @@ extern HB_EXPORT const char * hb_verFlagsPRG( void ); /* retrieves a stat
extern HB_EXPORT const char * hb_verHB_PLAT( void ); /* retrieves a static buffer containing build time HB_PLATFORM setting */
extern HB_EXPORT const char * hb_verHB_COMP( void ); /* retrieves a static buffer containing build time HB_COMPILER setting */

extern HB_EXPORT HB_BOOL hb_iswin9x( void ); /* return HB_TRUE if OS == Windows 9x, ME */
extern HB_EXPORT HB_BOOL hb_iswinnt( void ); /* return HB_TRUE if OS == Windows NT or newer */
extern HB_EXPORT int hb_iswine( void ); /* return non-zero if OS == Wine */
extern HB_EXPORT int hb_iswin9x( void ); /* return non-zero if OS == Windows 9x, ME */
extern HB_EXPORT int hb_iswinnt( void ); /* return non-zero if OS == Windows NT or newer */
extern HB_EXPORT HB_BOOL hb_iswin2k( void ); /* return HB_TRUE if OS == Windows 2000 or newer */
extern HB_EXPORT HB_BOOL hb_iswin2k3( void ); /* return HB_TRUE if OS == Windows 2003 Server or newer */
extern HB_EXPORT HB_BOOL hb_iswinvista( void ); /* return HB_TRUE if OS == Windows Vista or newer */
extern HB_EXPORT HB_BOOL hb_iswin7( void ); /* return HB_TRUE if OS == Windows 7 or newer */
extern HB_EXPORT HB_BOOL hb_iswin8( void ); /* return HB_TRUE if OS == Windows 8 or newer */
extern HB_EXPORT HB_BOOL hb_iswin81( void ); /* return HB_TRUE if OS == Windows 8.1 or newer */
extern HB_EXPORT HB_BOOL hb_iswin10( void ); /* return HB_TRUE if OS == Windows 10 or newer */
extern HB_EXPORT HB_BOOL hb_iswince( void ); /* return HB_TRUE if OS is Windows CE or Windows Mobile */
extern HB_EXPORT HB_BOOL hb_iswinver( int iMajorVersion, int iMinorVersion, int iType, HB_BOOL fOrUpper );
extern HB_EXPORT HB_BOOL hb_iswinver( int iMajor, int iMinor, int iType, HB_BOOL fOrUpper );
extern HB_EXPORT HB_BOOL hb_iswinsp( int iServicePackMajor, HB_BOOL fOrUpper );

extern HB_EXPORT HB_BOOL hb_printerIsReady( const char * pszPrinterName );

Expand Down
Loading

0 comments on commit 8545d4b

Please sign in to comment.