Paul
Paul

Reputation: 219

Boolean parameter in a dll function in delphi 7

I have a dll library. I have excluded memory unit for delphi types.

In that way, what would be the appropriate Boolean type for function declaration?

Is it BOOL or something else?

The problem is that in the method signature:

function Test(Param1: BOOL; Param2: BOOL; docContent: PCharArray): Integer;

I get AV when program leaves that function.

I assume that it is the problem with the data type of these two first parameters.

Upvotes: 3

Views: 1744

Answers (1)

Rob Kennedy
Rob Kennedy

Reputation: 163287

BOOL is fine for Boolean types. It's a Windows type, so it's what you'll see in all the functions in Windows.pas.

Access violations upon return from a DLL function often indicate that you have the calling convention wrong — the default calling convention is register, but you probably need stdcall or cdecl. Add it at the end of the declaration:

function Test(Param1: BOOL; Param2: BOOL; docContent: PCharArray): Integer; stdcall;

Upvotes: 6

Related Questions