On Mon, 25 Jun 2007 03:17:00 -0700, Josemi <josemiant...@gmail.com>
wrote:
My God, How can I do to solve it?
P.D.: I use VC++ v6.0. I can't to built the dll in MBCS mode
What do you mean here in P.D.?
(BTW: I don't like very much DLL exposing C++ interfaces; IMHO if one
wants to expose an object interface in a DLL, better using
object-orientation in pure C (like using handles, etc.) or use COM.)
Back to your problem.
My understand of your problem is:
 1. you have the DLL built using VC++6 in MBCS mode
 2. you cannot modify/rebuild your DLL
 3. you have the app built using VC++6 in Unicode mode
 4. you cannot build your app in MBCS mode
So, I think that you may need an "interface" wrapper DLL to solve your
problem, because if you are in VC++6 and are in Unicode mode, CString
will be considered Unicode strings, and so there is a strong impedence
with the DLL expecting a CString in MBCS...
So you may need an "interface" DLL, to be built with VC++6.
 +--------------------+
 | Your app (Unicode) |
 +--------------------+
           |
 +--------------------+
 |    Wrapper DLL     |  <-- converts Unicode -> MBCS
 +--------------------+
           |
 +--------------------+
 | MBCS original DLL  |
 +--------------------+
Assume that the function in your MBCS DLL is:
  bool FunctionMBCS( const CString & stringMBCS );
Then the wrapper DLL should define a function like so:
  // This must be called by the client app
  bool WrapperFunction( const WCHAR * stringUnicode );
Your app must call the WrapperFunction:
  // In your app:
  CString s; // Unicode, in your app
  // Call the wrapper function in wrapper DLL
  // (not the original MBCS DLL)
  boob ret = WrapperFunction( static_cast<const WCHAR *>(s) );
The wrapper function converts from Unicode to MBCS:
The wrapper DLL must be compiled in *MBCS* mode (so CString is MBCS):
  bool WrapperFunction( const WCHAR * stringUnicode )
  {
      //
      // Convert from Unicode to MBCS, and call the
      // original MBCS DLL function
      //
      ... Use ::WideCharToMultiByte to convert from
      ... stringUnicode to MBCS.
      ... Store the MBCS string in 'mbcs':
      CString mbcs;
      mbcs = ...
      // Pass the MBCS converted string to MBCS DLL
      return FunctionMBCS( mbcs );
  }
MrAsm
P.D.: = post data, P.S.:. There is a definition in
I like your answer, but I don't idea about this technique. I must to
study it.