Documentation using WIN32 API

Stack Layout during API call

API Parameter types:

boolean

Four bytes are passed. The object must be a Boolean. This corresponds to type BOOL in C.

double

Eight bytes are passed. This type is intended for use with double-precision floating-point arguments such as class Float.

handle

The first four bytes of the object are passed. The object can be a variableByteSubclass and will usually be an ExternalHandle (or one of its subclasses).long Four bytes are passed. The object may be an integer in the range of -2147483648 .. +2147483647 (0x80000000 .. 0x7FFFFFFF), or it can be a byte object, and the first four bytes are passed. This corresponds to type LONG in C.

self

The object pointer itself is passed. This is used by user-defined DLL functions.

short

Four bytes are passed. The object may be an integer in the range of -32768 .. +32767 (0x8000 .. 0x7FFF), or it can be a byte object, and the first two bytes are passed. This corresponds to type SHORT in C.

struct

The four-byte address of the bytes of the object are passed. The object must be a variableByteSubclass and will usually be an ExternalBuffer. This type is used when the C argument is a pointer, such as a PSZ.

structIn

A struct pointer argument which is an IN parameter, i.e., the caller makes no changes to the structure. This is a performance optimization of the existing struct argument type.

structOut

A struct pointer argument which is an OUT parameter, i.e., the initial state of the structure is not specified and the caller will set the values. This is a performance optimization of the existing struct argument type.

structValue

This is a structure argument which is passed by value. For example, a POINTL argument is an 8-byte structure passed by value on the call stack, in contrast to a PPOINTL argument, which is a pointer to a POINTL structure

ulong

Four bytes are passed. The object may be a positive integer the range of 0..4294967295 (0xFFFFFFFF), or it can be a byte object, and the first four bytes are passed. This corresponds to type ULONG in C

ushort

Four bytes are passed. The object may be a positive integer in the range of 0 to 65535 (0xFFFF), or it can be a byte object and the first two bytes are passed. This corresponds to type USHORT in C.

API return types:

hresult

A 32-bit return value of type HRESULT. This return type is used extensively in OLE, but can also be used in non-OLE API’s.

none

Is specified if the function does not return a value. This is equivalent to declaring VOID in C

short

A 2-byte Integer, signed

ushort

A 2-byte Integer, unsigned

boolean

A 4-byte Boolean

long

A 4-byte Integer, signed

ulong

A 4-byte String, representing an unsigned integer quantity

ulongReturn

A 4-byte Integer, unsigned

double

An 8-byte Float, signed

handle

A variableByteObject (String) from which an appropriate ExternalHandle can be obtained via fromBytes: (Note: handle is actually the same as ulong)

Documentation of the api parameter types is taken from Smalltalk for Windows Manual – Copyright by Cincom Inc.


API parameter encoding:

Compiled methods that contain the api: keyword have two special literals in their variable part:

  • a string with the name of the API function
  • a byte array that encodes the arguments and return types and also caches the address of the api call. The first four bytes of this array are the address cache. The next byte is the number of arguments plus one (the return type), followed by a corresponding number of bytes each indicating the argument type / return type according to this table:

short

1

long

2

boolean

3

ushort

4

ulong

5

struct

6

handle

7

self

8

none

9

double

10

ulongReturn

11

selfIndirect

12

structValue

13

structIn

14

structOut

15

hresult

16