DLL example?
Posted: Tue Apr 09, 2024 11:20 am
Hello,
I am trying to understand the DLL concept in PureBasic for the first time.
The examples provided in the help file are not runable, or I am missing something.
The below code can be found in the help file, tab 'Index', "Declare DLL":
Simply Pressing F5 on this, does nothing visible.
As it is not very well explained, I think I must save the block procedureDLL - EndProcedure only as PureBasic.dll... How do we save that as a DLL??? No explanation there. If I'm doing that in the PB editor, I'm selecting File/Save As, then selecting "All files (*.*)" and write "PureBasic.dll" in the File name field, then press the Save button. The editor screen then becomes pale yellow (instead of my black background), and the .dll file is an Ascii file, prefixing with  (Hex EF BB BF 0D 0A).
And the block "; Now the client program...." as a standard .pb
Running the standard .pb has only the effect to show a warning message that says that PureBasic.dll is wrong or contains an error... (Error 0xc000012f).
Cheers
I am trying to understand the DLL concept in PureBasic for the first time.
The examples provided in the help file are not runable, or I am missing something.
The below code can be found in the help file, tab 'Index', "Declare DLL":
Code: Select all
ProcedureDLL MyFunction()
MessageRequester("Hello", "This is a PureBasic DLL !", 0)
EndProcedure
; Now the client program, which use the DLL
;
If OpenLibrary(0, "PureBasic.dll")
CallFunction(0, "MyFunction")
CloseLibrary(0)
EndIf
As it is not very well explained, I think I must save the block procedureDLL - EndProcedure only as PureBasic.dll... How do we save that as a DLL??? No explanation there. If I'm doing that in the PB editor, I'm selecting File/Save As, then selecting "All files (*.*)" and write "PureBasic.dll" in the File name field, then press the Save button. The editor screen then becomes pale yellow (instead of my black background), and the .dll file is an Ascii file, prefixing with  (Hex EF BB BF 0D 0A).
And the block "; Now the client program...." as a standard .pb
Running the standard .pb has only the effect to show a warning message that says that PureBasic.dll is wrong or contains an error... (Error 0xc000012f).
Cheers
