U
Unknown
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.
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.