Skip to content

API

Interface to the Microsoft Windows API

This directive enables a Thoroughbred Basic program to call functions from the Microsoft Windows application-programming interface (API).

API(library$, function$[, argument-1, . . ., argument-n])
library$
is the name of a library.
function$
is the name of a function.
argument
is an argument that will be passed to the function. For more information on how arguments are passed, please refer to the following section.

The Thoroughbred Basic Environment for Windows requires that Microsoft Win32s be installed if the Microsoft environment is not a 32-bit system. For example, if you plan to use the API directive in Microsoft Windows 3.1, you must have Win32s installed.

The API directive can return a string or number, depending on context.

API functions require arguments to be passed by reference or passed by value:

  • All strings are passed by reference.
  • All numeric constants are passed by value.
  • Numeric variables are passed by reference.
  • Expressions are evaluated then passed by value.
  • To pass a variable by value, you must add 0 as part of the argument. For example, N+0 passes the numeric variable N by value.

The following types of functions are not supported:

  • Functions that require callback functions, such as timers or enumerators.
  • Functions that require structures.
  • Third-party libraries that require real numbers.

Sample programs that include multiple API calls are included in the Thoroughbred Basic Environment for Windows software.

A = API("User32","GetFocus")
B = API("User32","ShowWindow",A+0,2)

returns the window handle as an integer, then displays the window in minimized state.

DIM B$(256)
B = API("User32","GetWindowText",A+0,B$,LEN(B$))

puts the window text in B$.

Information on the Microsoft Windows API available from Microsoft or other publishers

From the Thoroughbred Basic Language Reference, Volume I: A–E, version 8.9.1. Open this page in the PDF