fix GetVersionExA is Deprecated warning

This commit is contained in:
v-kaywon 2017-06-29 12:23:46 -07:00
parent fb64892e37
commit b78bcf8be3
5 changed files with 7 additions and 11 deletions

View file

@ -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;

View file

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

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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