Page 1 of 1

convert dll-call

Posted: Wed Nov 25, 2015 12:30 pm
by t57042
Help needed to adapt:

Code: Select all

 Prototype  sluConvertDat(a,b,c,d,e)
according description below.
How obtain result?
Thanks - Richard

Code: Select all

'===========================<[ 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.
__________________________________________________
Code-tags added
25.11.2015
RSBasic

Re: convert dll-call

Posted: Wed Nov 25, 2015 12:41 pm
by Keya
i cant run to test it but perhaps something like this

Code: Select all

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)

Re: convert dll-call

Posted: Wed Nov 25, 2015 4:26 pm
by Lunasole
Somethink like this using pointers:

Code: Select all

; declare 
Prototype sluConvertDat.i (*DataIn, LengthOfDataIn.l, *DataOut, *SizeOfDataOut, *ModChars)

; call
Result = sluConvertDat (@DataIn, 512, @DataOut, @SizeOut, @ModChars)