Kaydet (Commit) 163dcad7 authored tarafından skswales's avatar skswales Kaydeden (comit) Michael Stahl

Work towards tdf#72606

EasyHack _tstring/TCHAR elimination

These were already compiled UNICODE - changes for clarity and consistency

Change-Id: I846063ddf37af80b3a8787b45d97215e1770c0f3
Reviewed-on: https://gerrit.libreoffice.org/24859Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst c5ab14e2
......@@ -18,6 +18,7 @@
*/
#define UNICODE
#define _UNICODE
#ifdef _MSC_VER
#pragma warning(push,1) // disable warnings within system headers
......@@ -31,21 +32,21 @@
#include <string.h>
#include <malloc.h>
#include <stdio.h>
#include "strsafe.h"
#include <strsafe.h>
#include <seterror.hxx>
#include "seterror.hxx"
BOOL GetMsiProp( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
BOOL GetMsiPropW( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
{
DWORD sz = 0;
if ( MsiGetProperty( hMSI, pPropName, const_cast<wchar_t *>(L""), &sz ) == ERROR_MORE_DATA )
if ( MsiGetPropertyW( hMSI, pPropName, const_cast<wchar_t *>(L""), &sz ) == ERROR_MORE_DATA )
{
sz++;
DWORD nbytes = sz * sizeof( wchar_t );
wchar_t* buff = reinterpret_cast<wchar_t*>( malloc( nbytes ) );
ZeroMemory( buff, nbytes );
MsiGetProperty( hMSI, pPropName, buff, &sz );
MsiGetPropertyW( hMSI, pPropName, buff, &sz );
*ppValue = buff;
return TRUE;
......@@ -56,18 +57,18 @@ BOOL GetMsiProp( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
#ifdef DEBUG
inline void OutputDebugStringFormat( LPCTSTR pFormat, ... )
inline void OutputDebugStringFormatW( PCWSTR pFormat, ... )
{
TCHAR buffer[1024];
WCHAR buffer[1024];
va_list args;
va_start( args, pFormat );
StringCchVPrintf( buffer, sizeof(buffer), pFormat, args );
OutputDebugString( buffer );
StringCchVPrintfW( buffer, sizeof(buffer)/sizeof(buffer[0]), pFormat, args );
OutputDebugStringW( buffer );
va_end(args);
}
#else
static inline void OutputDebugStringFormat( LPCTSTR, ... )
static inline void OutputDebugStringFormatW( PCWSTR, ... )
{
}
#endif
......@@ -75,21 +76,21 @@ static inline void OutputDebugStringFormat( LPCTSTR, ... )
extern "C" UINT __stdcall CheckVersions( MSIHANDLE hMSI )
{
// MessageBox(NULL, L"CheckVersions", L"Information", MB_OK | MB_ICONINFORMATION);
// MessageBoxW(NULL, L"CheckVersions", L"Information", MB_OK | MB_ICONINFORMATION);
wchar_t* pVal = NULL;
if ( GetMsiProp( hMSI, L"NEWPRODUCTS", &pVal ) && pVal )
if ( GetMsiPropW( hMSI, L"NEWPRODUCTS", &pVal ) && pVal )
{
OutputDebugStringFormat( TEXT("DEBUG: NEWPRODUCTS found [%s]"), pVal );
OutputDebugStringFormatW( L"DEBUG: NEWPRODUCTS found [%s]", pVal );
if ( *pVal != 0 )
SetMsiErrorCode( MSI_ERROR_NEW_VERSION_FOUND );
free( pVal );
}
pVal = NULL;
if ( GetMsiProp( hMSI, L"OLDPRODUCTS", &pVal ) && pVal )
if ( GetMsiPropW( hMSI, L"OLDPRODUCTS", &pVal ) && pVal )
{
OutputDebugStringFormat( TEXT("DEBUG: OLDPRODUCTS found [%s]"), pVal );
OutputDebugStringFormatW( L"DEBUG: OLDPRODUCTS found [%s]", pVal );
if ( *pVal != 0 )
SetMsiErrorCode( MSI_ERROR_OLD_VERSION_FOUND );
free( pVal );
......
......@@ -18,6 +18,7 @@
*/
#define UNICODE
#define _UNICODE
#ifdef _MSC_VER
#pragma warning(push,1) // disable warnings within system headers
......@@ -30,24 +31,24 @@
#include <string.h>
#include <malloc.h>
#include <stdio.h>
#include "strsafe.h"
#include <strsafe.h>
#include <seterror.hxx>
#include "seterror.hxx"
#ifdef DEBUG
inline void OutputDebugStringFormat( LPCTSTR pFormat, ... )
inline void OutputDebugStringFormatW( PCWSTR pFormat, ... )
{
TCHAR buffer[1024];
WCHAR buffer[1024];
va_list args;
va_start( args, pFormat );
StringCchVPrintf( buffer, sizeof(buffer), pFormat, args );
OutputDebugString( buffer );
StringCchVPrintfW( buffer, sizeof(buffer)/sizeof(buffer[0]), pFormat, args );
OutputDebugStringW( buffer );
va_end(args);
}
#else
static inline void OutputDebugStringFormat( LPCTSTR, ... )
static inline void OutputDebugStringFormatW( PCWSTR, ... )
{
}
#endif
......@@ -55,19 +56,19 @@ static inline void OutputDebugStringFormat( LPCTSTR, ... )
void SetMsiErrorCode( int nErrorCode )
{
const TCHAR sMemMapName[] = TEXT( "Global\\MsiErrorObject" );
const WCHAR sMemMapName[] = L"Global\\MsiErrorObject";
HANDLE hMapFile;
int *pBuf;
hMapFile = OpenFileMapping(
hMapFile = OpenFileMappingW(
FILE_MAP_ALL_ACCESS, // read/write access
FALSE, // do not inherit the name
sMemMapName ); // name of mapping object
if ( hMapFile == NULL ) // can not set error code
{
OutputDebugStringFormat( TEXT("Could not open map file (%d).\n"), GetLastError() );
OutputDebugStringFormatW( L"Could not open map file (%d).\n", GetLastError() );
return;
}
......@@ -82,7 +83,7 @@ void SetMsiErrorCode( int nErrorCode )
UnmapViewOfFile( pBuf );
}
else
OutputDebugStringFormat( TEXT("Could not map view of file (%d).\n"), GetLastError() );
OutputDebugStringFormatW( L"Could not map view of file (%d).\n", GetLastError() );
CloseHandle( hMapFile );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment