Page 1 of 1

Setting up program Global values from DLL

Posted: Fri Aug 08, 2008 5:55 pm
by Chirantha
Hi,

I need to define some global values from the DLL. But its not working

The code in program

Code: Select all

dllh=OpenLibrary(#PB_Any,"firstdll.dll")
Debug dllh
Debug CallFunction(dllh,"SetGlobalval")

MessageRequester("Test",DLLreturn$)
End
The code in DLL

Code: Select all

ProcedureDLL SetGlobalval()
  Global DLLreturn$
  DLLreturn$="I set the value!"
  ProcedureReturn 1
EndProcedure

Posted: Fri Aug 08, 2008 5:59 pm
by Kaeru Gaman
a Global in a DLL is only global within the DLL.

you should not need to define a Global inside a DLL to be accessable in the calling program.
if you think you need it, your concept is wrong.

Posted: Fri Aug 08, 2008 6:02 pm
by srod
You can of course return the address of the global variable and then use one of the Peek functions or even use a pointer to get a hold of the data etc.

As Kaeru says though, returning a global from a dll is not really a great idea! :wink: