|
-
Mar 11th, 2008, 09:41 PM
#13
Re: VB6 Vista UAC Problem
MkDir is also a function that doesn't support Unicode. It fails since there is no folder "?". A lot of VB's native functions coerce to ANSI, including all the file handling functions. If you want to handle Unicode filenames, you have to use Unicode aware API calls.
Byte arrays are directly converted to strings without applying ANSI coercion. The same happens the other way around, you can apply a string to a byte array and Unicode is preserved. It is a direct memory copy of the string where nothing is ever changed.
StrConv(bytArray, vbUnicode) actually just adds in extra zero bytes, although I guess it may also work a bit by the locale and apply certain character codes above the 255 byte range, and thus use the equivalent Unicode character codes instead. I haven't really tested it too well, or, I can't remember how it worked if I did test it out at some point.
I made my own test program. I changed the folder "C:\Users\Vesa\Favorites\" to "C:\Users\Vesa\ふぁヴぉりてす\"
Then I ran this simple code (also having the module I posted above):
Code:
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function DrawText Lib "user32" Alias "DrawTextW" (ByVal hDC As Long, ByVal lpStr As Long, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
Private Sub Form_Load()
Me.ScaleMode = vbPixels
End Sub
Private Sub Form_Paint()
Dim bytText() As Byte, udtRECT As RECT
bytText = GetSystemPath([Path Favorites]) & "\"
With udtRECT
.Bottom = Me.ScaleHeight
.Right = Me.ScaleWidth
End With
DrawText Me.hDC, VarPtr(bytText(0)), (UBound(bytText) + 1) \ 2, udtRECT, 0
End Sub
Nicely shows you the Japanese there, and that the function works as I told
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|