convert dll-call

Just starting out? Need help? Post your questions and find answers here.
t57042
Enthusiast
Enthusiast
Posts: 203
Joined: Fri Feb 22, 2008 12:28 pm
Location: Belgium

convert dll-call

Post 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
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: convert dll-call

Post 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)
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: convert dll-call

Post 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)
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Post Reply