From b78bcf8be31ccd50feb7458dc8085e2180db9826 Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Thu, 29 Jun 2017 12:23:46 -0700 Subject: [PATCH] fix GetVersionExA is Deprecated warning --- source/shared/core_init.cpp | 10 +++------- source/shared/core_sqlsrv.h | 2 +- source/shared/core_stream.cpp | 2 +- source/shared/core_util.cpp | 2 +- source/sqlsrv/php_sqlsrv.h | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/source/shared/core_init.cpp b/source/shared/core_init.cpp index 724ada5f..37e7d584 100644 --- a/source/shared/core_init.cpp +++ b/source/shared/core_init.cpp @@ -18,11 +18,12 @@ //--------------------------------------------------------------------------------------------------------------------------------- #include "core_sqlsrv.h" +#include "VersionHelpers.h" // module global variables (initialized in minit and freed in mshutdown) HMODULE g_sqlsrv_hmodule = NULL; -OSVERSIONINFO g_osversion; +bool isVistaOrGreater; // core_sqlsrv_minit @@ -47,12 +48,7 @@ void core_sqlsrv_minit( _Outptr_ sqlsrv_context** henv_cp, _Inout_ sqlsrv_contex #ifdef _WIN32 // get the version of the OS we're running on. For now this governs certain flags used by // WideCharToMultiByte. It might be relevant to other things in the future. - g_osversion.dwOSVersionInfoSize = sizeof( g_osversion ); - BOOL ver_return = GetVersionEx( &g_osversion ); - if( !ver_return ) { - LOG( SEV_ERROR, "Failed to retrieve Windows version information." ); - throw core::CoreException(); - } + isVistaOrGreater = IsWindowsVistaOrGreater( ); #endif //_WIN32 SQLHANDLE henv = SQL_NULL_HANDLE; diff --git a/source/shared/core_sqlsrv.h b/source/shared/core_sqlsrv.h index 719c77c9..5e5421d1 100644 --- a/source/shared/core_sqlsrv.h +++ b/source/shared/core_sqlsrv.h @@ -1000,7 +1000,7 @@ struct sqlsrv_encoding { //********************************************************************************************************************************* // variables set during initialization -extern OSVERSIONINFO g_osversion; // used to determine which OS we're running in +extern bool isVistaOrGreater; // used to determine if OS is Vista or Greater extern HashTable* g_encodings; // encodings supported by this driver void core_sqlsrv_minit( _Outptr_ sqlsrv_context** henv_cp, _Inout_ sqlsrv_context** henv_ncp, _In_ error_callback err, _In_z_ const char* driver_func TSRMLS_DC ); diff --git a/source/shared/core_stream.cpp b/source/shared/core_stream.cpp index 4fc1cfe3..513527de 100644 --- a/source/shared/core_stream.cpp +++ b/source/shared/core_stream.cpp @@ -155,7 +155,7 @@ size_t sqlsrv_stream_read( _Inout_ php_stream* stream, _Out_writes_bytes_(count) // convert to UTF-8 #ifdef _WIN32 DWORD flags = 0; - if( g_osversion.dwMajorVersion >= SQLSRV_OS_VISTA_OR_LATER ) { + if( isVistaOrGreater ) { // Vista (and later) will detect invalid UTF-16 characters and raise an error. flags = WC_ERR_INVALID_CHARS; } diff --git a/source/shared/core_util.cpp b/source/shared/core_util.cpp index a003f718..61f66bdb 100644 --- a/source/shared/core_util.cpp +++ b/source/shared/core_util.cpp @@ -141,7 +141,7 @@ bool convert_string_from_utf16( _In_ SQLSRV_ENCODING encoding, _In_reads_bytes_( // flags set to 0 by default, which means that any invalid characters are dropped rather than causing // an error. This happens only on XP. DWORD flags = 0; - if( encoding == CP_UTF8 && g_osversion.dwMajorVersion >= SQLSRV_OS_VISTA_OR_LATER ) { + if( encoding == CP_UTF8 && isVistaOrGreater ) { // Vista (and later) will detect invalid UTF-16 characters and raise an error. flags = WC_ERR_INVALID_CHARS; } diff --git a/source/sqlsrv/php_sqlsrv.h b/source/sqlsrv/php_sqlsrv.h index 59ed2c5f..82168296 100644 --- a/source/sqlsrv/php_sqlsrv.h +++ b/source/sqlsrv/php_sqlsrv.h @@ -99,7 +99,7 @@ extern HMODULE g_sqlsrv_hmodule; // used for getting the versio extern sqlsrv_context* g_ss_henv_cp; extern sqlsrv_context* g_ss_henv_ncp; -extern OSVERSIONINFO g_osversion; // used to determine which OS we're running in +extern bool isVistaOrGreater; // used to determine if OS is Vista or Greater #define phpext_sqlsrv_ptr &g_sqlsrv_module_entry