Re: App Unicode call MBCS dll
MrAsm wrote:
On Tue, 26 Jun 2007 13:53:51 -0500, David Wilkinson
<no-reply@effisols.com> wrote:
Not even by having a .cpp file that opted out of the Unicode settings
for the rest of the application?
I did not test that...
But I don't know if it would be possible, in the same application, to
do something like this:
- turn Unicode off (e.g. #undef UNICODE, _UNICODE etc.)
- use CString (in ANSI mode)
- turn Unicode on
- use CString in Unicode mode
I don't know if it would be possible, and if it would be robust and
not cause bugs...
Asm:
I don't think you have to turn it back on in the same translation unit.
Just have one translation unit that operates entirely in MBCS. Something
like
<untested>
// wrapper.h
// C interface can be included anywhere
bool bWrapDameValorINI (char* valor, int nLen, const char* clave, const
char*variable, const char* nombre_ficheroINI, bool obligatorio);
//wrapper.cpp
#ifdef UNICODE
#undef UNICODE
#endif
#ifdef _UNICODE
#undef _UNICODE
#endif
#include <afx.h>
#include "dll_header.h"
#include "wrapper.h"
bool bWrapDameValorINI (char* valor, int nLen, const char* clave, const
char*variable, const char* nombre_ficheroINI, bool
obligatorio)
{
CString strValor; // MBCS
bool bResult = bDameValorINI (strValor, clave, variable,
nombre_ficheroINI, obligatorio); // DLL
if(!bResult || nLen < strValor.Getlength())
{
return false;
}
strcpy(valor, strValor);
return true;
}
</untested>
--
David Wilkinson
Visual C++ MVP