'===========================<[ ConvertDat ]>===========================
Declare Sub sluConvertDat lib "SQLiteningU.Dll" alias "sluConvertDat" ( _
byval DataIn as Long, _
byval LengthOfDataIn as Long, _
byval DataOut as Long, _
byref SizeOfDataOut as Long, _
byval ModChars as Long)
' DataIn is a pointer to the memory containing the data to be converted.
' LengthOfDataIn contains the length of the data to be converted.
' DataOut is a pointer to the returning converted data.
' SizeOfDataOut is both passed and returned. Pass the size of DataOut.
' It must be at least the size of the returning converted data.
' The actual length of the returing converted data is returned.
' If the passed size is too small then the returning length will
' be set to -1.
' ModChars is a pointer to a null-terminated string. If not needed you
' may pass a zero.
Prototype.i proto_sluConvertDat(*DataIn, LengthOfDataIn.l, *DataOut, pSizeOfDataOut.i, ModChars.l)
Define hLib.i, SizeOfDataOut.l, MyString.s, DataOut.i
MyString.s = "main string of data, an SQL statement or whatever it is!"
SizeOfDataOut = Len(MyString)
DataOut = AllocateMemory(SizeOfDataOut) ;must be big enough to store result. If you just want it as a string instead of memory alloc perhaps change to "DataOut.s = Space(SizeOfData)"
hLib.i = OpenLibrary(#PB_Any, "SQLiteningU.dll")
If hLib = 0
MessageRequester("Error","Couldnt load dll")
End
EndIf
sluConvertDat.proto_sluConvertDat = GetFunction(hLib, "sluConvertDat")
If sluConvertDat = 0
MessageRequester("Error","Couldnt find function in dll")
CloseLibrary(hLib): End
EndIf
sluConvertDat(@MyString, Len(MyString), DataOut, @SizeOfDataOut, ModChars) ;note SizeOfDataOut is BYREF
If SizeOfDataOut = -1
MessageRequester("Error", "Allocated buffer size is too small")
Else
MessageRequester("Result", Str(SizeOfDataOut) + " bytes. Data=" + PeekS(@DataOut, -1, #PB_Unicode)) ;guessing the U in SQLiteningU.dll means it wants unicode not ascii
EndIf
CloseLibrary(hLib)