Unicode strange behaviour
Posted: Tue Aug 29, 2017 1:09 pm
Hello at all
Today, i have again a strange behaviour to show
I use VB6 sometime, for calling PB dll
But like now, VB is unicode only, all my VB6 program not works when i recompile the old DLL with v5.60
Apparently VB6 is UNICODE, but call library fonction in ASCII, it's the reason why all works very well with v5.40 and ASCII compilation
So i have use the UTF8() function for convert the ASCII variable from VB6, and that not works
VB6 code
Pb Dll
Since 4 hours, i have all try with VB and PB, and i have no new idea
But the worst, that works with this function "Ansi2Uni", and not with Fred UTF8() function
If someone understand something
Have a good day

Today, i have again a strange behaviour to show

I use VB6 sometime, for calling PB dll
But like now, VB is unicode only, all my VB6 program not works when i recompile the old DLL with v5.60

Apparently VB6 is UNICODE, but call library fonction in ASCII, it's the reason why all works very well with v5.40 and ASCII compilation

So i have use the UTF8() function for convert the ASCII variable from VB6, and that not works

VB6 code
Code: Select all
Public Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Public Declare Function LoadLibraryA Lib "kernel32" (ByVal lpLibFileName As Any) As Long
Public Declare Function EssaiVb6 Lib "LaDll.dll" Alias "Essai" (ByVal Texte As String) As Long
Private Sub Form_Load()
ChDir App.Path
HwndLib = LoadLibraryA(App.Path + "\LaDll.dll")
EssaiVb6("A que coucou les quéqués")
FreeLibrary HwndLib
End Sub
Code: Select all
ProcedureDLL.s Essai(Texte.s)
*UTF8 = UTF8(Texte)
Texte = PeekS(*UTF8, -1, #PB_UTF8)
MessageRequester("Unicode variable", Texte)
ProcedureReturn Texte
EndProcedure

But the worst, that works with this function "Ansi2Uni", and not with Fred UTF8() function

Code: Select all
Procedure.l Ansi2Uni(ansi.s)
size.l=MultiByteToWideChar_(#CP_ACP,0,ansi,-1,0,0)
Dim unicode.w(size)
MultiByteToWideChar_(#CP_ACP, 0, ansi, Len(ansi) * 2, unicode(), size)
ProcedureReturn @unicode()
EndProcedure
ProcedureDLL.s Essai(Texte.s)
*pointeur = Ansi2Uni(Texte)
Texte = PeekS(*pointeur)
MessageRequester("Unicode variable", Texte)
ProcedureReturn Texte
EndProcedure
Have a good day