Licence
MIT
Version
2.0.0
Deps
1
Size
77 kB
Vulns
0
Weekly
17
@bun-win32/netapi32
Zero-dependency, zero-overhead Win32 NETAPI32 bindings for Bun on Windows.
Overview
@bun-win32/netapi32 exposes the netapi32.dll exports using Bun's FFI. It provides a single class, Netapi32, which lazily binds native symbols on first use. You can optionally preload a subset or all symbols up-front via Preload().
The bindings are strongly typed for a smooth DX in TypeScript.
Features
- Bun-first ergonomics on Windows 10/11.
- Direct FFI to
netapi32.dll(users, groups, shares, sessions, servers, workstations, domain joins, WebDAV, DC locator, and more). - In-source docs in
structs/Netapi32.tswith links to Microsoft Docs. - Lazy binding on first call; optional eager preload (
Netapi32.Preload()). - No wrapper overhead; calls map 1:1 to native APIs.
- Strongly-typed Win32 aliases (see
types/Netapi32.ts).
Requirements
- Bun runtime
- Windows 10 or later
Installation
bun add @bun-win32/netapi32Quick Start
import Netapi32, { NERR_Success } from '@bun-win32/netapi32';
// Optionally bind a subset up-front
Netapi32.Preload(['NetWkstaGetInfo', 'NetApiBufferFree']);
// Query workstation info
const buf = Buffer.alloc(8);
const status = Netapi32.NetWkstaGetInfo(null, 100, buf.ptr);
if (status === NERR_Success) {
console.log('NetWkstaGetInfo succeeded.');
}
Netapi32.NetApiBufferFree(buf.ptr);AI agents: see
AI.mdfor the package binding contract and source-navigation guidance. It explains how to use the package without scanning the entire implementation.
Examples
Run the included examples:
bun run example # Workstation info + user enumerationNotes
- Either rely on lazy binding or call
Netapi32.Preload(). - Windows only. Bun runtime required.