Using DLLs

Just starting out? Need help? Post your questions and find answers here.
ac667788
User
User
Posts: 10
Joined: Sun May 13, 2007 6:50 am

Using DLLs

Post by ac667788 »

Am curious about the use of DLLs

I wrote a DLL with a single function

Code: Select all

#include <stdio.h>

void hello ()
  {
    printf ("Hello World!\n");
  }
I verified the DLL was written correctly and could actually see the "hello" function name using LibrayFunctionName() but when I run the following code, "Hello World" fails to show up in the console.

Code: Select all

If OpenLibrary(0, "mydll.dll") 
  OpenConsole()
    CallFunction(0,"hello")
    Delay(2000)
    CloseConsole()  
EndIf
CloseLibrary(0)
I rewrote the hello function as an addition returning an integer and that seems to work but why doesn't printf?
cxAlex
User
User
Posts: 88
Joined: Fri Oct 24, 2008 11:29 pm
Location: Austria
Contact:

Post by cxAlex »

You must use CallCFunction() for C DLLs.
DarkDragon
Addict
Addict
Posts: 2347
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

Have you compiled with Console-mode?

Anyway, in PureBasic on Windows... I don't think there's standard-output pipelining.
cxAlex wrote:You must use CallCFunction() for C DLLs.
No, definately not just for C DLLs. You can specify cdecl or stdcall in C and for cdecl you need CallC and for stdcall you need Call.
bye,
Daniel
Post Reply