Code: Select all
ProcedureDLL MyFunction()
MessageRequester("Hello", "This is a PureBasic DLL !", 0)
EndProcedure
Code: Select all
; Now the client program, which use the DLL
;
If OpenLibrary(0, "my.dll")
CallFunction(0, "MyFunction")
CloseLibrary(0)
Else
MessageRequester("error", "i could not locate the dll", 0)
EndIf
End
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - DLL example file
;
; (c) 2002 - Fantaisie Software
;
; ------------------------------------------------------------
;
; This example is a skeleton to build easely a DLL using PureBasic
; The dll is created in the 'Compilers' directory, under the
; 'purebasic.dll' name. An associated '.lib' is generated to use
; with LccWin32 or VisualC++.
;
;
; Rules to follow:
; - Never write code outside a procedure, except for variables
; or structure declaration.
;
; - DirectX Init routines must not be initialized in the the
; AttachProcess() procedure
;
; - There is 4 procedures automatically called: AttachProcess(),
; DetachProcess(), AttachThread() and DetachThread(). If you don't
; need them, just remove them.
;
#TESTDLL = 0
CompilerIf #TESTDLL = 0
; This procedure is called once, when the program loads the library
; for the first time. All init stuffs can be done here (but not DirectX init)
;
ProcedureDLL AttachProcess(Instance)
EndProcedure
; Called when the program release (free) the DLL
;
ProcedureDLL DetachProcess(Instance)
EndProcedure
; Both are called when a thread in a program call or release (free) the DLL
;
ProcedureDLL AttachThread(Instance)
EndProcedure
ProcedureDLL DetachThread(Instance)
EndProcedure
; Real code start here..
;
ProcedureDLL EasyRequester(Message$)
MessageRequester("EasyRequester !", Message$, #MB_ICONINFORMATION)
EndProcedure
CompilerElse
If OpenLibrary(0, "PureBasic.dll")
CallFunction(0, "EasyRequester", "Test")
EndIf
CompilerEndIf
; ExecutableFormat=Shared Dll
; Executable=C:\Programmation\Projets\PureBasic Visual Designer\Dll.Exe
; DisableDebugger
; EOF
question2. Do the last for lines do anything, or are they just regular comments?
..