I need call a DLL file in my delphi code, here is the code snippet of the DLL Head file:
#define BookInfoDLL __declspec(dllexport)
struct _BookTime
{
unsigned char day;
unsigned char month;
unsigned short year;
};
struct _stBookData
{
unsigned char encrypt;
_BookTime bkTime;
unsigned int PageCount;
};
int BookInfoDLL UpdateBooks(const char * const pBookID,
const char cBookTypeWord,
const _stBookData * const pBookData,
const int nBookDataCounter);
I need invoke the dll function “UpdateBooks” in my delphi code.
How can I convert those code into delphi? Thank you!
Snippet for non-managed Delphi code (not tested, but compiles and changed according suggestions in comments):
Simple call
UpdateBooks(...)from delphi code.Update: code changed, thanks for commenting!
Below is snippets for sample calls …
Common functions and constants for all snippets:
Calling function in common Delphi style:
Bonus: same test calls in C-style and Pascal-style 🙂