App crash with wrong parameter

My app crash when trying to send a byte array as 2nd parameter to a dll, in the external methods I set Declare Function ImgOpenFile Lib “C:\Libs\IOF.dll” (Param1 As Integer, Param2 As Ptr) As Integer

Dim Str As New MemoryBlock(9)

Dim SS As String
SS = ChrB(67) + ChrB(58) + ChrB(92) + ChrB(73) + ChrB(68) + ChrB(46) + ChrB(106) + ChrB(112) + ChrB(103)
Str.StringValue(0,8) = SS
TmpFlag = ImgOpenFile (0, Str)

What Im doing wrong?

Thanks in advance…

I don’t know if this is the problem, but you’re constructing a string of 9 bytes, but only loading 8 into the memoryblock.

Hi Tim, sorry for that, my code is corrrect, my question is, this is the correct way to send a byte array as parameter to a DLL?