#include "stdafx.h"
#pragma hdrstop
//---------------------------------------------------------------------------
/* Win95Compat.cpp
Copyright (C) 2010 by Daniel Marschall
This file is part of TZipMaster Version 1.9.
TZipMaster is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TZipMaster is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with TZipMaster. If not, see .
contact: problems@delphizip.org (include ZipMaster in the subject).
updates: http://www.delphizip.org
DelphiZip maillist subscribe at http://www.freelists.org/list/delphizip
************************************************************************/
//---------------------------------------------------------------------------
// Use CharNextCompat() instead of CharNext().
// It will automatically use CharNextA() or CharNextW() and will use
// failsafe code if CharNextW() is not implemented in the users'
// Windows version.
#ifdef UNICODE
LPWSTR WINAPI CharNextCompat(IN LPCWSTR lpsz) {
LPWSTR ret = CharNextW(lpsz);
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED /* 120 */ ) {
// See also: Cows\userW.cpp, Line 146
if (*lpsz) ++lpsz;
return const_cast(lpsz);
} else {
return ret;
}
}
#else
LPSTR WINAPI CharNextCompat(IN LPCSTR lpsz) {
return CharNextA(lpsz);
}
#endif
//---------------------------------------------------------------------------
// Use WideCharToMultiByteOptionalFlags() instead of WideCharToMultiByte()
// if you are using flags which might not exist on prior operating systems.
// Do only use this function if you can accept the behavior of dwFlags set to 0.
int WINAPI WideCharToMultiByteOptionalFlags(
UINT CodePage,
DWORD dwFlags,
LPCWSTR lpWideCharStr,
int cchWideChar,
LPSTR lpMultiByteStr,
int cbMultiByte,
LPCSTR lpDefaultChar,
LPBOOL lpUsedDefaultChar
) {
int ret = WideCharToMultiByte(
CodePage,
dwFlags,
lpWideCharStr,
cchWideChar,
lpMultiByteStr,
cbMultiByte,
lpDefaultChar,
lpUsedDefaultChar
);
// For older OS compatibility:
// Drop the flags if at least one of them is unknown to the OS
if (GetLastError() == ERROR_INVALID_FLAGS /* 1004 */ ) {
ret = WideCharToMultiByte(
CodePage,
0,
lpWideCharStr,
cchWideChar,
lpMultiByteStr,
cbMultiByte,
lpDefaultChar,
lpUsedDefaultChar
);
}
return ret;
}
//---------------------------------------------------------------------------