In XP should the "W" functions in the API

  • Thread starter Thread starter active
  • Start date Start date
A

active

In windows XP and VB.NET should the "W" functions in the Windows API be
used or should the "A" functions be used

I'm looking at a type library and see things like the following:

#ifdef UNICODE

entry("lstrlenW"),

#else

entry("lstrlenA"),

#endif

I think both VB and XP use unicode so it seems that converting to ASCII is
not necessary. I'm not sure VB and XP can talk to each other in Unicode. Can
they?
 
In windows XP and VB.NET should the "W" functions in the Windows API be
used or should the "A" functions be used

Preferrably the W version, since it's better for performance (as you
said yourself, ANSI conversion is unnecessary). Generally, the best
solution is to use the Auto modifier keyword in the Declare statement
for these functions, and let the rungime decide which function, A or
W, to call depending on the platform.



Mattias
 
* "active said:
In windows XP and VB.NET should the "W" functions in the Windows API be
used or should the "A" functions be used

On Windows XP the "W" (Unicode) function is preferred.
I think both VB and XP use unicode so it seems that converting to ASCII is
not necessary. I'm not sure VB and XP can talk to each other in Unicode. Can
they?

I would declare the function as 'Auto' ('Public Declare Auto Function...').

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
 
Active,
When you use the Declare statement its recommended you use Auto and .NET
will take care of the A & W and the encoding (based on Adam Nathan's ".NET
and COM - The Complete Interoperability Guide" from SAMs press).

Declare Auto Function CreateFile Lib "kernel32.dll" ByVal (fileName As
String, ...)

DllImport has a similar option. Adam's book covers the details.

Hope this helps
Jay
 
Back
Top