Call with a raw address to produce a caller. Without an argument, or with
0/0n, it is a NULL function pointer (address 0n, as Python's
P()); calling it throws Error exception: access violation writing 0x0000000000000000 (or rejects for callAsync/callOn). P(null) is a
TypeError, as in Python.
Optionaladdress: number | bigintCall with a JS function to produce a directly callable, typed C callback,
usable as an argument or struct field. Keep it referenced while C may
call it; release() frees it. As in Python, a prototype whose restype
is a POINTER, a function pointer, a structure or an array cannot make
callbacks (TypeError invalid result type for callback function).
Bind an exported function of a library, optionally with paramflags.
Python: prototype((name, dll)) / prototype((name, dll), paramflags).
Bind a COM vtable slot by index (prototype(vtblIndex, name[, paramflags[, iid]])),
Windows only (a TypeError elsewhere, as in Python). Each call takes the
interface as its first argument: a ctypes instance holding the interface
pointer (a POINTER instance, c_void_p, a Structure, a Buffer), not a
number, BigInt or byref().
Optionalparamflags: readonly (ParamFlag | readonly [number, string, any])[]Optionaliid: unknownOptionaladdress: number | bigintShared metadata; assigning it does not recompile the captured signature.
Shared metadata; mutating it does not recompile the captured signature.
Readonly_Bind the factory to a library export with Python-style paramflags.
Out params are allocated automatically and returned alone (one value or
an array). Returning the original args from errcheck keeps this behavior.
callAsync() uses the same output processing and per-call hook snapshot.
Python ctypes parity: prototype((name, lib), paramflags).
const proto = WINFUNCTYPE(DWORD, HWND, LPDWORD);
const fn = proto.bind(user32, "GetWindowThreadProcessId", [
{ dir: "in", name: "hWnd" },
{ dir: "out", name: "pid" },
]);
const pid = fn(hwnd); // positional; thread ID is discarded
const pid2 = fn({ hWnd: hwnd }); // named
const pid3 = await fn.callAsync(hwnd); // async, same output processing
CPython from_param: an instance of this prototype (or an object whose
_as_parameter_ is one) is returned; other values throw TypeError
expected CFunctionType instance instead of <type>.
Python Prototype.in_dll(lib, name): a function pointer read once from
the exported variable name (a global function pointer). A missing
symbol throws RangeError symbol 'name' not found.
Factory returned by CFUNCTYPE / WINFUNCTYPE.