Re: Unicode String Parameters in DLL's



Cool. Thanks Tom. I have a routine that grabs the text before the trailing
zero.

Thanks again.

"Tom Winter" <tom@xxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:OKMaP%23fNFHA.2508@xxxxxxxxxxxxxxxxxxxxxxx
> You've probably heard something wrong about "VBA's automatic converting to
> ANSI". Strings in VB6 and VBA are Unicode. (The forms package in VB6 it
> NOT Unicode, so you might have heard some stuff about that. VBA's forms
> package is Unicode.) I do this exact same kind of thing when calling
> Windows Unicode APIs. VB/VBA will see the Unicode characters put in your
> "buffer" by your DLL just fine. It doesn't so any kind of conversion
> before or after the DLL call.
>
> One thing to watch out for is if your DLL routine puts a zero byte at the
> end of the string. To VBA, a zero byte is just another character in the
> string (Chr$(0)); it does not terminate the string. You'll need a routine
> to scan where the zero byte is and then only take the text before that
> zero byte. I can give you a function for that if you need.
>
> --
> Tom Winter
> tom@xxxxxxxxxxxxxxxxxxxxxx
>
> "Unknown" <unknown@xxxxxxxxxxx> wrote in message
> news:_%B2e.8089$zl.7227@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> We are converting our application to work with Unicode. The Word macro
>> in our application "communicates" with our main application via a C DLL.
>> This DLL includes several functions which return Unicode strings back to
>> the macro as input parameters. My question is, what is the correct
>> declaration for the DLL functions in VBA?
>>
>> I currently have it working like this:
>>
>> Private Declare Function GetUserName Lib "MyDLL.dll" (ByVal lpUser As
>> Long) As Integer
>>
>> GetUserName simply copies the user name into a Unicode string.
>>
>> I call this function from VBA code with something like this:
>>
>> Dim sUser as String
>> sUser = String(255, Asc(" "))
>>
>> GetUserName StrPtr(sUser)
>>
>> This seems to work, but I've only tested it with standard characters
>> (i.e. nothing outside of the normal Latin character set). I'm concerned
>> about VBA's automatic converting to ANSI, although I don't really
>> understand what that means... Does it mean that VBA will convert the
>> sUser string to ANSI when I try to access it, and so any characters
>> outside of the ANSI set will be converted to question marks or something
>> like that?
>>
>> Any help you can give me on this would be greatly appreciated.
>>
>
>


.



Relevant Pages

  • Re: Unicode vs UTF-16 vs UTF-8
    ... interface is over the HTTPD web server, and a web browser on a separate ... The decision was to NOT work with unicode except on the ... when I use APIs that require a string such as a filename for FTP? ... lot of network stuff is constantly converting back and forth. ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Outlook is not Unicode compliant, is it?
    ... My question is then whether Outlook 2003 saves me from ... doing the string conversion since it supports Unicode. ... > sets and language encodings by converting Unicode to an 8-bit string encoded ...
    (microsoft.public.outlook)
  • Re: Unicode conversion
    ... A unicode is two bytes, so converting it to that will in my idea not help you. ... Still have to read into a string then decode. ... > Imports System.Web ...
    (microsoft.public.dotnet.languages.vb)
  • Re: how can one variable equal 2 things??
    ... be a boolean true since the variable exists and is not NULL, but testing if == 1 returns FALSE. ... If you compare a string to a number, an attempt is made to convert that string to a number first. ... If the string starts with valid number data, then that will be the used value, otherwise the comparison will be against zero. ... as well as the section on converting ...
    (comp.lang.php)
  • Re: convert GB to Big5
    ... >I found out I can use strconvfor converting GB to unicode and then ... >converting it to Big5. ... > DECLARE integer LCMapString IN WIN32API integer, long, string, integer, ...
    (microsoft.public.fox.helpwanted)