Code: Select all
; testdll01.pb
EnableExplicit
Structure structureData
stringOne.s
stringTwo.s
stringThree.s
EndStructure
ProcedureDLL AttachProcess(instance)
EndProcedure
ProcedureDLL DetachProcess(instance)
EndProcedure
ProcedureDLL AttachThread(instance)
EndProcedure
ProcedureDLL DetachThread(instance)
EndProcedure
ProcedureDLL concatString(*memLoc.structureData)
Protected partOne.s = *memLoc\stringOne
Protected partTwo.s = *memLoc\stringTwo
Protected partThree.s = partOne + partTwo
*memLoc\stringThree = partThree
EndProcedure
; IDE Options = PureBasic 4.51 (Windows - x64)
; ExecutableFormat = Shared Dll
; CursorPosition = 1
; Folding = -
; Executable = testdll01.dll
; CurrentDirectory = D:\dev\PureBasic\temp\
; CompileSourceDirectoryCode: Select all
; testing01.pb
EnableExplicit
Structure structureData
stringOne.s
stringTwo.s
stringThree.s
EndStructure
Procedure ProcessThis()
Protected libraryfile0.s = "testdll01.dll"
Protected libraryNumber0
Protected *thisData.structureData
*thisData.structureData = AllocateMemory(SizeOf(structureData))
*thisData\stringOne = "This is string one, "
*thisData\stringTwo = "this is string two"
; open the library if needed, then run the dll
libraryNumber0 = OpenLibrary(#PB_Any, libraryfile0)
PrintN("OpenLibrary " + libraryfile0 + " = " + Str(libraryNumber0))
If libraryNumber0 > 0
CallFunction(libraryNumber0, "concatString", *thisData)
PrintN(*thisData\stringThree)
Else
PrintN("Unable to run CallFunction concatString")
EndIf
ClearStructure(*thisData, structureData)
FreeMemory(*thisData)
EndProcedure
OpenConsole()
ProcessThis()
Input()
CloseConsole()
End
; IDE Options = PureBasic 4.51 (Windows - x64)
; Folding = -
; ExecutableFormat = Console
; CurrentDirectory = D:\dev\PureBasic\temp\
; CompileSourceDirectoryIf I create a new process by removing the call to the dll, and just call the procedure as normal, all is fine:
Code: Select all
; testing02.pb
EnableExplicit
Structure structureData
stringOne.s
stringTwo.s
stringThree.s
EndStructure
Procedure concatString(*memLoc.structureData)
Protected partOne.s = *memLoc\stringOne
Protected partTwo.s = *memLoc\stringTwo
Protected partThree.s = partOne + partTwo
*memLoc\stringThree = partThree
EndProcedure
Procedure ProcessThis()
Protected *thisData.structureData
*thisData.structureData = AllocateMemory(SizeOf(structureData))
*thisData\stringOne = "This is string one, "
*thisData\stringTwo = "this is string two"
; open the library if needed, then run the dll
concatString(*thisData)
PrintN(*thisData\stringThree)
ClearStructure(*thisData, structureData)
FreeMemory(*thisData)
EndProcedure
OpenConsole()
ProcessThis()
Input()
CloseConsole()
End
; IDE Options = PureBasic 4.51 (Windows - x64)
; Folding = -
; ExecutableFormat = Console
; CurrentDirectory = D:\dev\PureBasic\temp\
; CompileSourceDirectory