Page 1 of 1
Passing string to DLL truncates to first character
Posted: Thu Nov 20, 2014 2:46 pm
by PeterJ
Hello,
when passing a string to a DLL (also PB), only the first character is received in the DLL. I was able to reproduce it with one of the Help examples:
Code: Select all
Prototype.i ProtoMessageBox(Window.i, Body$, Title$, Flags.i = 0)
If OpenLibrary(0, "User32.dll")
MsgBox.ProtoMessageBox = GetFunction(0, "MessageBoxA")
MsgBox(0, "Hello", "World") ; wir geben keine Flags an
EndIf
The message box pops up with the header "H" and Text "W".
Numeric parameters work find.
I am running PB 5.31; 5.30 shows same behaviour.
Peter
Re: Passing string to DLL truncates to first character
Posted: Thu Nov 20, 2014 2:59 pm
by Little John
PeterJ wrote:Hello,
when passing a string to a DLL (also PB), only the first character is received in the DLL. I was able to reproduce it with one of the Help examples:
Code: Select all
Prototype.i ProtoMessageBox(Window.i, Body$, Title$, Flags.i = 0)
If OpenLibrary(0, "User32.dll")
MsgBox.ProtoMessageBox = GetFunction(0, "MessageBoxA")
MsgBox(0, "Hello", "World") ; wir geben keine Flags an
EndIf
The message box pops up with the header "H" and Text "W".
Use MessageBoxA when your program is compiled in ASCII mode,
use MessageBoxW when your program is compiled in Unicode mode.
And your self-made DLL should be compiled in the same mode as your program, which calls functions in that DLL.
Re: Passing string to DLL truncates to first character
Posted: Thu Nov 20, 2014 3:14 pm
by PeterJ
... there is always something
This was exactly the reason! Thanks for quick any easy solution!
Now my DLL perfectly runs !
Peter
Re: Passing string to DLL truncates to first character
Posted: Thu Nov 20, 2014 3:15 pm
by skywalk
Even though PB is dropping Ascii compiles, you can still access Ascii libs with pseudotypes.
Code: Select all
Prototype.i ProtoMessageBox(Window.i, Body.p-Ascii, Title.p-Ascii, Flags.i = 0)
If OpenLibrary(0, "User32.dll")
MsgBox.ProtoMessageBox = GetFunction(0, "MessageBoxA")
MsgBox(0, "Hello", "World") ; wir geben keine Flags an
EndIf
Re: Passing string to DLL truncates to first character
Posted: Thu Nov 20, 2014 3:24 pm
by Little John
Oh yes, I forgot about pseudotypes.