DLL Procedure Parameters and C Data Types

When you define a parameter for a procedure that you are exporting from a DLL, you must specify the parameter's data type in ATEasy. First check the DLL vendor's documentation to see the data type of the parameter in the DLL. Then match that data type with its ATEasy equivalent. The tables below contain a list of Windows and C/C++ data types and their ATEasy equivalents.

 

Windows C Data Type

 ATEasy Equivalent

BOOL

Val Long ( 0 for false, 1 for true )

BOOLEAN

Val Long ( 0 for false, 1 for true )

BSTR

Val BString

BYTE

Val Byte

CHAR

Val Char

CY

Val Currency

CALLBACK*

Val Procedure

DATE

Val DateTime

DECIMAL

Val Decimal

DOUBLE

Val Double

DWORD

Val DWord

FLOAT

Val Float

HANDLE

Val AHandle

HRESULT

Val Long

IDispatch *

Val Object

INT

Val Long

LONG

Val Long

LPARAM

Val Long

LRESULT

Val Long

SCODE

Val Long

SHORT

Val Short

OLECHAR

Val WChar

UCHAR

Val Byte

UINT

Val DWord

ULONG

Val DWord

USHORT

Val Word

VARIANT

Val Variant

VARIANTARG

Val Variant

VARIANT_BOOL

Val Bool ( 0 for false, -1 for true )

VARTYPE

Val Word

WCHAR, wchar_t

Val WChar

WORD

Val Word

WPARAM

Val DWord

PBOOL, LPBOOL

Var Long

LPBSTR

Var BString

PBYTE, LPBYTE

Var Byte

PCH, LPCH

Var Char

PCHAR, LPCHAR

Var Char

LPCOLESTR

Val BString

PCSTR, LPCSTR

Val String

PCWSTR, LPCWSTR

Val BString

LPDECIMAL

Var Decimal (you need to create struct called Decimal)

PDWORD, LPDWORD

Var DWord

PFLOAT

Var Float

PINT, LPINT

Var Long

PLONG, LPLONG

Var Long

LPOLESTR

Val/Var BString ( Val if input only, else Var )

PSHORT

Var Short

PUINT

Var DWord

LPVARIANT

Var Variant

LPVARIANTARG

Var Variant

PVOID, LPVOID

Var Any

PWCH, LPWCH

Var WChar

PWCHAR

Var WChar

PWORD, LPWORD

Var Word

PWSTR, LPWSTR

Val/Var BString ( Val if input only, else Var )

 

C Data Type

 ATEasy Equivalent

bool

Val Char ( 0 for false, -1 for true )

char

Val Char

double

Val Double

float

Val Float

int

Val Long

long, long int

Val Long

short, short int

Val Short

unsigned char

Val Byte

unsigned short

Val Word

unsigned int

Val DWord

unsigned long

Val DWord

void *

Var Any, Val APointer

ATEasy's Any type accepts both VAL and Var type.

When a parameter is explicitly declared to be a pointer with an asterisk (that is, type * variable_name) and type has an ATEasy equivalent of Val xxx, you must change the ATEasy Val type to ATEasy Var. in C a pointer parameter can also be declared in ATEasy as array parameter depends on the description  of that parameter.

If a C function returns a pointer to data (for example array, structure or even a pointer to a basic data type), in ATEasy it should be declared as APointer  (4 or 8 bytes value to hold the pointer depends on the run-time used 32 or 64-bit), Use the ATEasy  MemoryCopy internal function to set or get the value from the pointer.

In ATEasy 5.0, for a callback function as DLL procedure parameter, you can declare as Val param of type Procedure.  The procedure would be either one that defined in ATEasy or a DLL Procedure.  The validity of Procedure's (callback function's) definition cannot be checked by ATEasy, thus it is the user's responsibility to make sure exactly to define what is being required for its parameters.  Please see an example for callback function.

The following table demonstrates what is passed when ATEasy argument to DLL function parameter:

 

ATEasy Data Type

VAL

VAL [ ]

VAR

 VAR [ ]

Simple Data Type *

the data **

pointer to the first element of the array

pointer to the data

pointer to the first element of the array

String

pointer to the first character of the string

 

 

 

BString

pointer to the first character of the BString

 

 

 

Variant

 

 

 

 

Procedure

 

 

 

 

Object

 

 

 

 

Any

 

 

 

 

APointer

 

 

 

 

* Simple Data type - Char, Byte, Short, Bool, Word, WChar, Long, DWord, Dlong, DDWord, Float, Double, Currency, DateTime

** Callee cannot change the caller data