Unicode-Problem, VB<->C-DLL using Typelib + CString

Unicode-Problem, VB<->C-DLL using Typelib + CString

Post by Martin Koppman » Thu, 18 Oct 2001 19:12:21



Hello,

I want to pass a Unicode-String to a c-dll for fast manipulations with the

CString-class. Later I want to call other functions, only passing the
pointer to the CString. To avoid ANSI-conversions I made a typelib.
Unfortunately the returned

String is converted anyway.

I proved this by passing a string with japanese chars. The returned string

only contains '?' (AscW = 63, before AscW = 18789)

VB-Usage:

handle = InitializeString(sJapanese)  // nothing else is done between!

sReturned = GetString(handle)

Where is the Error? How can I avoid it?

Thank You very much for any hint,

Martin

-----------------------------

the Typelib:

    module StringFunctions

    {

     [entry("InitializeString")]

     long __stdcall InitializeString(

      [in] BSTR Source);

     [entry("GetString")]

     BSTR __stdcall GetString(

      [in] long rc);

------------------------------

the c-dll:

#define _Unicode

UINT __stdcall InitializeString(BSTR Source)

{

 CString *pCStr;

 pCStr = new CString(Source);

 return (UINT) pCStr;

Quote:}

BSTR __stdcall GetString(UINT sHandle)

{

 CString *pCStr = (CString*) sHandle;

 BSTR bstr = pCStr->AllocSysString();

 return bstr;

Quote:}

 
 
 

1. <><><> SCALA MM200 <><><>

Could anybody that uses Scala MM200, please get in touch to swap info and
scripts, or could anybody point me in the right
direction of where I can look for some demo scripts etc...

Scala MM200 is just excellent, i'am using MM200 to create cd-front menus
for conferences, which I then burn onto cd-rom with
my Yamaha CDR400c firmware 1.d

All the best - hope to hear from you soon...

- Steve -

2. How do i get DOS games running in the background in WIN 95

3. >>> Very weird problem in Win95b!!<<<<<<<

4. VCD on Media Player XP

5. <<>> COMPUTER SOFTWARE / HARDWARE <<>>

6. Display problem

7. >><>Services<><<

8. Intermitten printing

9. <><> 9,900 PROGRAMS ON CD-ROMS <><>

10. - - - = = =<><> W e b - U S A <><>= = = - - -

11. <<>> COMPUTER SOFTWARE / HARDWARE <<>>

12. >>>"What a problem?"<<<