Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

win32-api

waitingsong2kMIT26.1.2TypeScript support: included

FFI definitions of windows win32 api for node-ffi

windows, win32, api, kernel32, user32, comctl32, winspool, printer, ffi, koffi, Electron, ESM, typescript, ts

readme

win32-api

FFI Definitions of Windows win32 api for koffi

GitHub tag License Available platform ci codecov Conventional Commits lerna

Significant Changes.V22

Compile successfully with

  • Node.js v18
  • Node.js v20
  • Node.js v22

Migrate to v13

See migrate13

Packages

Package Version
win32-api main-svg
win32-def def-svg

What can I do with this?

Calling win32 native functions come from user32.dll, kernel32.dll, comctl32.dll by Node.js via node-ffi-napi

Installing

npm install win32-api

Usage

DLL Wrapper

import { 
  FindWindow, 
  GetDefaultPrinter,
} from 'win32-api/util'

// Retrieves the printer name of the default printer for the current user on the local computer
const printerName = await GetDefaultPrinter()

const child = spawn('notepad.exe')
const hWnd = await FindWindowEx(0, 0, 'Notepad', null)

Demo

Relevant

License

MIT

Languages

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

26.1.2 (2025-02-26)

Bug Fixes

  • win32-def: missing dep "@waiting/shared-types" (9e048a4)

26.1.1 (2024-12-26)

Note: Version bump only for package win32-api

26.1.0 (2024-12-19)

Note: Version bump only for package win32-api

26.0.4 (2024-12-13)

Bug Fixes

26.0.3 (2024-09-24)

Note: Version bump only for package win32-api

26.0.2 (2024-07-07)

Bug Fixes

26.0.1 (2024-07-02)

Bug Fixes

  • def: revert HANDLE def to uint32 | uint64 (22c8002)

26.0.0 (2024-07-02)

Features

  • def: add DLGPROC (6423edc)
  • def: change HANDLE def to 'void*' (01a3df8)

25.0.0 (2024-07-01)

Bug Fixes

  • def: type WNDPROC, WNDCLASSEXW_Type (3e8e72a)

Features

  • api: change user32 parameters def to D.WString (e6b7389)
  • def: change LPVOID to HANDLE (1308dca)

24.2.0 (2024-07-01)

Features

  • api: kernel32 GetProcAddress() (9cec31a)
  • api: kernel32 LoadLibraryExW() (de59df2)

24.1.0 (2024-06-30)

Features

  • api: user32 CallWindowProcW() (3aa6467)

24.0.0 (2024-06-30)

Features

  • remove types T.LPMSG, T.LPPOINT (1d7e972)

23.3.0 (2024-06-30)

Features

  • win32-api: user32 GetClassLongPtrW() (d25d02a)

23.2.0 (2024-06-30)

Features

  • win32-api: user32 GetClassNameW() (3b7913f)

23.1.0 (2024-06-30)

Features

  • win32-api: add UnregisterClassW(), update GetClassInfoExW() (c5a7408)

23.0.0 (2024-06-30)

Features

  • win32-def: breaking change WNDCLASSEXW (72e6432)

22.7.3 (2024-06-30)

Bug Fixes

  • win32-def: ucsBufferToString() (cb68da5)

22.7.2 (2024-06-30)

Bug Fixes

22.7.1 (2024-06-30)

Note: Version bump only for package win32-api

22.7.0 (2024-06-28)

Features

  • win32-api: user32 ShowWindowAsync() (de0b542)

22.6.0 (2024-06-28)

Features

  • win32-api: user32 ChangeDisplaySettingsExW() (1f0d8f9)

22.5.1 (2024-06-28)

Note: Version bump only for package win32-api

22.5.0 (2024-06-28)

Features

  • win32-api: user32 EnumChildWindows() (28912b4)

22.4.0 (2024-06-28)

Features

  • win32-api: /util/ MessageBox() (dc2e3d6)
  • win32-api: user32 MessageBoxExW() (435a07c)

22.3.0 (2024-06-28)

Features

  • win32-api: user32 GetRawInputData() (645ce4b)

22.2.0 (2024-06-28)

Features

  • win32-def: struct RAWINPUT (4b492ba)
  • win32-def: struct RAWMOUSE (1f0c54b)

22.1.0 (2024-06-28)

Features

  • win32-api: user32 SetParent() (421b405)

22.0.0 (2024-06-28)

Features

  • use koffi instead of ffi-napi to support nodejs >= 18 (3e8f7b5)
  • win32-api: change const enum to normal enum (21b8d17)
  • win32-def: update properties of VirtualKey (bb091d7)

21.0.2 (2024-06-16)

Note: Version bump only for package win32-api

21.0.1 (2024-06-16)

Note: Version bump only for package win32-api

21.0.0 (2024-06-16)

Features

  • win32-def: add enums (b5fdf54)
  • win32-def: breaking change re-expose Virtual-Key Codes via enum VirtualKey (ce5f8ca)

20.7.0 (2024-06-14)

Features

  • win32-api: user32.SendMessageTimeoutW() (76f81cb)

20.6.0 (2024-06-14)

Features

  • win32-api: user32.BroadcastSystemMessage() (3b7a546)
  • win32-api: user32.RegisterWindowMessageW() (3161b1b)

20.5.0 (2024-06-14)

Note: Version bump only for package win32-api

20.4.1 (2023-02-11)

Note: Version bump only for package win32-api

20.4.0 (2023-02-06)

Note: Version bump only for package win32-api

20.3.0 (2023-02-06)

Bug Fixes

  • boilerplate: define enum without const (37ffd10)
  • boilerplate: devDeps version (2e29b42)

20.2.0 (2022-12-22)

Features

  • win32-api: winspool GetJobW() 4f63359

20.1.0 (2022-09-01)

Features

  • win32-api: user32.MonitorFromWindow() 271e9ac

20.0.0 (2022-08-29)

Note: Version bump only for package win32-api

19.8.3 (2022-08-28)

Note: Version bump only for package win32-api

19.8.2 (2022-08-26)

Note: Version bump only for package win32-api

19.8.1 (2022-07-26)

Bug Fixes

  • boilerplate: define enum without const 37ffd10
  • boilerplate: devDeps version 2e29b42

19.8.0 (2022-07-26)

Features

  • win32-api: def const DefGroupNumber, DefGroupPointer 694835b
  • win32-api: retrieveStructFromPtrAddress() accept 3rd param 27b87fa
  • win32-api: spoolss.EnumPrintProcessorsW() d023967
  • win32-api: winspool apis 2d5b833
  • win32-api: winspoolEnumPrintProcessorDatatypes() a3eca83
  • win32-api: winspoolEnumPrintProcessors() 9fd9bde
  • win32-def: change DOC_INFO_1 f10020f

19.7.0 (2022-07-25)

Features

  • win32-api: def DLL spoolss b879bbf
  • win32-api: export fun/spoolss e050e4d
  • win32-api: export spoolss 349c143
  • win32-api: winspool.StartDocPrinterW() 0b9bd65
  • win32-api: winspool.StartPagePrinter() 3fddfd6
  • win32-api: winspool.WritePrinter() 588145a

19.6.0 (2022-07-25)

Features

  • win32-def: StructPropToWCHAR, StructPropToBuffer ba40d35

19.5.0 (2022-07-25)

Features

  • win32-api: helper bufferToStruct() 86539fd

19.4.0 (2022-07-24)

Features

  • win32-def: struct DATATYPES_INFO_1 e4a6253
  • win32-def: struct PRINTPROCESSOR_INFO_1 590c087

19.3.0 (2022-07-24)

Features

  • win32-def: DOC_INFO_1 6700cad
  • win32-def: update items of enum Def 74dc6d1

19.2.2 (2022-07-22)

Note: Version bump only for package win32-api

19.2.1 (2022-07-22)

Note: Version bump only for package win32-api

19.2.0 (2022-07-22)

Features

  • win32-api: retriveStruct_PRINTER_INFO() accept 3th param pcbNeeded 2588e65

19.1.0 (2022-07-22)

Features

  • win32-api: winspool.EnumPrintersW(), winspoolEnumPrinters() e7c1e01

19.0.0 (2022-07-22)

Features

  • win32-api: breaking change ReturnType of retriveStruct_PRINTER_INFO() 83d2b0a

18.4.0 (2022-07-22)

Features

  • win32-def: def EnumPrinters_Level 91f4f00

18.3.0 (2022-07-22)

Features

  • win32-api: ptrToString() cb09884
  • win32-api: ucsBufferSplit() accept 2nd param fe82533
  • win32-def: add Def.uint16PtrPtr 14cefcd
  • win32-def: enum PrinterEnumFlags 097fc39

18.2.0 (2022-07-22)

Features

  • win32-api: ClosePrinter(), winspoolClosePrinter() fff180f

18.1.0 (2022-07-22)

Features

  • win32-api: winspoolGetPrinter() c380490

18.0.0 (2022-07-22)

Features

  • win-def: StructCharOptions 0aa4846
  • win32-def: breaking change StructFactory(), StructType() accept 2nd options 6db7266
  • win32-def: breaking change type PRINTER_DEFAUL 95fba4c
  • win32-def: change property of StructCharOptions optional 36333e2

17.2.1 (2022-07-21)

Performance Improvements

  • win-def: BufferTypeFactory() string replace f1542ab

17.2.0 (2022-07-21)

Features

  • win32-def: update PRINTER_INFO_X with index sign 98419cd

17.1.1 (2022-07-21)

Note: Version bump only for package win32-api

17.1.0 (2022-07-20)

Features

  • win32-def: PRINTER_INFO_1 eca5a53

17.0.0 (2022-07-20)

Features

  • win32-api: breaking change genUcsBufferFrom() to ucsBufferFrom() 52cc0e5

16.0.1 (2022-07-20)

Bug Fixes

  • win32-api: fix char length of user32GetWindowText() e0d4a27

16.0.0 (2022-07-20)

Features

  • win32-api: breaking change nMaxCount not contains terminal-null 151878d
  • win32-api: breaking change return type of genUcsBufferFrom() fb18c7e
  • win32-api: remove undefined from return type of wrapper functions 80f75aa

15.1.0 (2022-07-20)

Features

  • win32-api: fun/user32GetWindowText() e672a2a
  • win32-api: ucsBufferToString() 7136eb3

15.0.0 (2022-07-20)

Features

  • win32-api: export User32 DLL Wrapper 6288392

14.1.0 (2022-07-20)

Features

  • win32-api: fun/winspoolOpenPrinter() 9aa25f2

14.0.0 (2022-07-20)

Features

  • win32-api: DLL Wrapper implementation d9502e3

13.15.0 (2022-07-20)

Features

  • win32-api: winspool.GetPrinterW() aac05fa
  • win32-api: winspool.OpenPrinterW() b557303

13.14.0 (2022-07-20)

Features

  • win32-api: add winspool module 5444af2

13.13.0 (2022-07-19)

Bug Fixes

  • win32-def: export /lib/struct/winspool.var.def.js 1761bca

Features

  • win32-def: def LPRINTER_DEFAULTS 2f4040c

13.12.0 (2022-07-19)

Features

  • win32-def: add struct and union types 016733b

13.11.0 (2022-07-19)

Features

  • win32-def: ACCESS_MASK c44979d
  • win32-def: struct POINTL 06ebc02

13.10.0 (2022-07-18)

Features

  • win32-api: gdi32.CreateCompatibleBitmap() 3325d3b

13.9.0 (2022-07-18)

Features

  • win32-api: gdi32.CreateCompatibleDC() 956587d

13.8.0 (2022-07-18)

Features

  • win32-api: user32.GetCaretPos() 62d7a11

13.7.0 (2022-07-18)

Features

  • win32-api: user32.FlashWindow() a0b1903
  • win32-api: user32.FlashWindowEx() c04b7af
  • win32-def: define FLASHWINFO structure 65022ea

13.6.0 (2022-07-17)

Bug Fixes

  • boilerplate: define enum without const 37ffd10
  • boilerplate: devDeps version 2e29b42

Features

  • win32-def: define Virtual-Key Codes 3d39823

13.5.0 (2022-07-04)

Features

  • win32-api: declare wingdi.enum.ts b94a11d

13.4.0 (2022-07-01)

Features

  • win32-def: declare StringBuffer.set() f96fe00

13.3.0 (2022-07-01)

Features

  • win32-def: export wcharBuffer() and BufferTypeFactory() 87a5fab

13.2.1 (2022-07-01)

Note: Version bump only for package win32-api

13.2.0 (2022-07-01)

Bug Fixes

  • win32-def: remove generic type of UnionType 588e41a
  • win32-def: rename UnionFactor() to UnionFactory() 86aa646

Features

  • win32-api: export UnionFactory cd5baff
  • win32-def: change generics type of UnionType() and struct() with StructTypeConstructor<T> 9f20e64

13.1.0 (2022-07-01)

Note: Version bump only for package win32-api

13.0.0 (2022-07-01)

Bug Fixes

  • boilerplate: define enum without const 37ffd10
  • boilerplate: devDeps version 2e29b42

Features

  • refactor types, defination, add promised API a1f1cc5

12.0.0 (2022-06-28)

Features

  • win32-api: add wcharBuffer() 7a584b1
  • win32-api: breaking change type BufferType to StringBuffer a79b7c2

11.1.1 (2022-06-28)

Note: Version bump only for package win32-api

11.1.0 (2022-06-28)

Features

  • win32-api: validate BufferType.encoding for setter 23540c4

11.0.3 (2022-06-28)

Note: Version bump only for package win32-api

11.0.2 (2022-06-27)

Bug Fixes

  • boilerplate: define enum without const 37ffd10
  • boilerplate: devDeps version 2e29b42

11.0.1 (2022-06-24)

Bug Fixes

  • boilerplate: define enum without const 37ffd10
  • boilerplate: devDeps version 2e29b42

11.0.0 (2022-06-22)

Bug Fixes

  • boilerplate: define enum without const 37ffd10
  • boilerplate: devDeps version 2e29b42

10.0.0 (2022-06-21)

Features

  • win32-api: retrieveStructFromPtrAddress() (8276042)

9.6.0 (2020-10-28)

Features

  • win32-api: add kernel32.GenerateConsoleCtrlEvent() ecc6fef

9.5.0 (2020-06-08)

Features

  • win32-api: export Constants 1f6c5eb
  • win32-api: export CS as alias of Constants 0e2f8e1
  • win32-api: update Constants b6f352f

9.4.0 (2020-06-07)

Bug Fixes

  • win32-api: gen_api_opts() 4615eaf

Features

  • win32-api: upgrade deps a53ae3e
  • win32-def: define structure COPYDATASTRUCT 96055f0

9.3.0 (2020-03-29)

Features

  • win32-api: add user32.PrintWindow() 2ef8b43

9.2.0 (2020-02-09)

Bug Fixes

  • win32-def: comments of HANDLE fecf53a

Features

  • win-def: add union support cadb3da
  • win32-api: add struct-ext RID_DEVICE_INFO 880b10b
  • win32-api: add user32.GetRawInputDeviceInfoW() 8f5d45f
  • win32-api: add user32.GetRawInputDeviceList() dcd6c35
  • win32-api: add user32.GetWindowRect() b3550bd
  • win32-api: add user32.SetForegroundWindow() 2b18384
  • win32-def: add RAWINPUTDEVICELIST structure 14ed2f4
  • add user32.GetAltTabInfoW() 3916c8e

9.1.0 (2020-02-06)

Features

  • add user EnumDisplayDevicesW() 9a9e321

9.0.0 (2020-01-21)

  • refactor!: change type of handle from Buffer to number (uint32/uint64) 47be79e

BREAKING CHANGES

  • the apis accept only number|bignum|string, no null any more

8.0.0 (2020-01-10)

  • chore(win32-def)!: remove deprecated types 99e1e5e

BREAKING CHANGES

  • remove deprecated types

7.1.0 (2020-01-10)

Bug Fixes

  • win32-def: struct MSG, MSG_Struct miss field lPrivate 81bea5d
  • win32-def: type of char 3e47988
  • win32-def: types of the following 9df3f28
  • win32-def: value of POINTER_32 is uint32 under x64 73b43ab

Features

  • win32-api: define CW_USEDEFAULT in user32/constants.ts 697e4df

7.0.2 (2019-12-23)

Note: Version bump only for package win32-api

7.0.1 (2019-12-23)

Note: Version bump only for package win32-api

7.0.0 (2019-12-23)

Bug Fixes

  • 'PVOID' not parsed within parse_windef() 3209b6c
  • LPBYTE 70cadc1
  • missing file marcomap.ts 692efbc
  • struct not parsed 0df3999
  • USN a246d16
  • types: parse_windef() 03de209

chore

  • deps: use ffi-napi instead of ffi bfa006c

Features

  • add FILETIME structure 2482e79
  • types: add DllFuncsModel d4b258b
  • types: change ReturnType of cb of async() from void to any 1f69876
  • types: expand exported DllFuncsModel with async() method 2cf076a
  • types: set below @deprecated d480b4b
  • add HARDWAREINPUT, HARDWAREINPUT_Struct 3ae64f3
  • add isPathAcessible() 01810da
  • add KEYBDINPUT, KEYBDINPUT_Struct 8ca6f3f
  • add LoadSettings['singleton'] 9be9d53
  • add logger() fe705c5
  • add LPPOINT d85e0a7
  • add MOUSEINPUT, MOUSEINPUT_Struct 60fb063
  • add RAWHID, RAWHID_Struct 2e5d09e
  • add RAWINPUTHEADER, RAWINPUTHEADER_Struct ca557fa
  • add RAWKEYBOARD, RAWKEYBOARD_Struct 9a3c56b
  • change types of VOID to number & Buffer & void e129f16
  • copy from node-win32-api and update 5e290b1
  • export basename() from shared a5ffb0b
  • export FModel.Buffer as alias of FModel.FFIBuffer 2a36d0f
  • export os.tmpdir() c98a3ab
  • rename export name of ww to dataTypes baf5a52
  • structure instance has ref() member for ref-struct 2b2b48e
  • use lookupRef() instead of retrieve_ref_value() e1f9497
  • types: change FFIParam to FnParam 8176abe

Reverts

  • to 84d3d698a5b1 d94d128

BREAKING CHANGES

  • deps: remove nodejs v8 support

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

6.2.0 (2019-10-11)

6.1.0 (2019-03-17)

Features

  • kernel32: add GetSystemTimes() (9a7587f)

3.9.0 (2019-02-22)

Features

  • add user32.PostMessageW() (7b02830)

3.8.0 (2019-02-22)

Features

  • add user32.SendMessageW() (a3036d6)

3.7.1 (2019-02-22)

3.7.0 (2019-02-21)

Bug Fixes

  • catch test error (5efe156)
  • createDir() path resolve under linux (c6d1274)
  • error TS1345: An expression of type 'void' cannot be tested for truthiness (0085713)

Features

  • add Observable functions (c9364db)
  • do isPathAccessible() first within isDirFileExists() (9ddae98)
  • export native assert() (683cea8)
  • export statAsync (c832590)
  • remove log() and logger() (27e1e29)