Page 1 of 1

External DLL usage in PB x64

Posted: Wed Jan 20, 2016 11:29 am
by agb2008
I am trying to find my way on how PureBasic x64 allow to use external libraries (.DLL)
Could anyone please help me by pinting at code example of different methods available in PB
for external DLL libraries access preferable with ability to download both PB sample code and
as well DLL library to run these tests on ?
Especially I am interested in differences between Prototype/PrototypeC and CallFuntionFast/
CallCFunctionFast differencies applicable to PureBasic x64 on Windows OS and x64 version of .dll
Thank you beforehand !

Re: External DLL usage in PB x64

Posted: Wed Jan 20, 2016 12:56 pm
by Kukulkan

Re: External DLL usage in PB x64

Posted: Wed Jan 20, 2016 3:10 pm
by JHPJHP
Hi agb2008,

As Kukulkan has suggested reading the documentation will help.

Here are some examples that include the binaries (x86 / x64):
PureBasic Interface to OpenCV
PureBasic Interface to WinDivert
PureBasic Interface to UnRAR (WinRAR)
PureBasic Interface to SevenZip (7-zip)
PureBasic Interface to ImDisk

Re: External DLL usage in PB x64

Posted: Wed Jan 20, 2016 6:42 pm
by agb2008
Kukulkan, JHPJHP:

Thank you for reply and suggestions. The reason I was asking was the case when I tried to test suggested
in the documentation methods and results were not so successful. Most of the functions were not working and
I was unable to find out that's the reason - issues with .dll files I was trying to use or the way how I was trying to
use it. That is why I was looking for existing example that I could play with and hopefully it would help me to
resolve issue with one I am planing to use now...

Re: External DLL usage in PB x64

Posted: Wed Jan 20, 2016 8:32 pm
by agb2008
Problem solved ! With help of PrototypeC construction usage. And it seems that part of initial issues were related to
the fact that I just moved from another flavour of Basic language into PureBasic and was not aware or certain ways
how programming have to be done here. :D

Re: External DLL usage in PB x64

Posted: Thu Sep 18, 2025 11:58 am
by acreis
Good Morning,

I'm trying to use a x64 sqlite.dll implementation found in https://github.com/utelle/SQLite3MultipleCiphers/.

Strangely it seems there is no difference using Prototype or PrototypeC.

Copilot says:

In Windows x64 there is no practical difference between `__cdecl`, `__stdcall`, or other calling conventions** like `__fastcall` when compiling a DLL or any code.

Structs and unions with sizes that match integers are passed and returned as if they were integers. Otherwise, they are replaced with a pointer when used as an argument. When a return of an oversized struct is needed, another pointer to a caller-provided space is prepended as the first argument, shifting all other arguments to the right by one place.[23]

When compiling for the x64 architecture in a Windows context (whether using Microsoft or non-Microsoft tools), stdcall, thiscall, cdecl, and fastcall all resolve to using this convention.

It seems its only necessary match the parameter count.

So this all should be ok

Prototype Proto_sqlite3_open_v2(filename.p-utf8, *pDb, flags, *ptrzVfs) ; flags is int32 but declared as int64
PrototypeC Proto_sqlite3_open_v2(filename.p-utf8, *pDb, flags, *ptrzVfs) ; flags is int32 but declared as int64
Prototype Proto_sqlite3_open_v2(filename.p-utf8, *pDb, flags.l, *ptrzVfs) ;flags is 32 bits and declared as int32 (purebasic long in x64)

Can anyone confirm this?

Re: External DLL usage in PB x64

Posted: Thu Sep 18, 2025 12:37 pm
by Fred
There is no difference between 'PrototypeC' and 'Prototype' on x64 but it's better to use the PrototypeC for these, as it's the purpose of it to stick to C convention (if you switch to x86 it will be difference).

Re: External DLL usage in PB x64

Posted: Thu Sep 18, 2025 3:31 pm
by acreis
Thanks Fred!

Receiving a response directly from you is a source of great honor and joy. I am deeply grateful for the attention and kindness shown in replying to me.