Purebasic-Tipps and Code > Purebasic Tipps

Using a Purebasic DLL from Powerbasic - Return a STRING to Powerbasic

(1/1)

Theo Gottwald:
Using a Purebasic DLL from Powerbasic is possible.
Yet its not as intuitive as it could be. I will give some examples that help on the Powerbasic Side.

Purebasic will return a STRING to Powerbasic.


--- Code: ---Asume this function is in a dll written in Purebasic 32-bit
;---------------------------------------------------------------------- 
; Returns a WSTRING to Powerbasic
  ProcedureDLL.s DName(T03.i)
    Protected S02.s{32768}
   T02=ExamineDesktops()
   If T02>0
     S01=DesktopName(T03)
   Else
     S01="" 
   EndIf
   S02=Trim(S01)
   ProcedureReturn S02
 EndProcedure   

--- End code ---

On the Powerbasic Side it will look like this:


--- Code: ---DECLARE FUNCTION DName LIB "XYZ.DLL" ALIAS "DName" (BYVAL A1 AS DWORD) AS WSTRING   

' This Function is a Sample how to Interface a Purebasic written DLL from Powerbasic
' Returning a STRING
FUNCTION Pure_Get_Desktop_Name(BYVAL U01 AS LONG) AS STRING
  LOCAL W01 AS WSTRING*32768
  LOCAL S01 as STRING
  W01=DName(R02)
  S01=TRIM$(W01)
  FUNCTION=S01
END FUNCTION

--- End code ---

Navigation

[0] Message Index

Go to full version