Strings Passed to DLLs in Variants Aren't Converted to ANSILast reviewed: October 30, 1995Article ID: Q138071 |
The information in this article applies to:
SUMMARYOn Win32 Operating systems, if a variant containing a UNICODE string is passed to a DLL, Visual Basic version 4.0 (32-bit version) does not automatically convert it to ANSI, as it would a UNICODE string that is passed directly.
MORE INFORMATIONVisual Basic version 4.0 (32-bit version) stores strings as UNICODE internally. So, if you assign a string to a variant in Visual Basic version 4.0 (32-bit), it will be stored as UNICODE. Now, if you pass this to a 32-bit DLL function either by reference or by value, Visual Basic will not automatically convert the string contained in the variant to ANSI. If you are building a UNICODE DLL or using a pre-existing UNICODE DLL, this is not a problem. However, for custom ANSI DLLs, you will have to convert the string to ANSI yourself, using the WideCharToMultiByte Windows API function inside the DLL, in order to actually use the string meaningfully. For pre-built ANSI DLLs, you must convert the Visual Basic version 4.0 UNICODE string to ANSI, using the StrConv function, assign it to the Variant, and then pass it to the DLL. You could use the latter approach for your own custom ANSI DLLs too.
|
Additional reference words: 4.00 vb4win vb432
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |