Real-world programs built with node-ctypes, written in the style of Python ctypes code. Most folders hold a reusable library, demo_*.js scripts and a README; the Electron example is a complete React desktop application.
| Example | Platforms | What it shows |
|---|---|---|
| Electron + React | macOS and Windows verified; Linux implementation included | Native clock, process ID, memory and per-processor load in live charts, typed sandboxed IPC, automatic synchronized native-memory mirrors, and ASAR packaging without an Electron-specific addon rebuild |
| Embedded Python | Windows, macOS, Linux | CPython loaded through its C API: code, modules and packages, callbacks, JavaScript objects by reference, shared memory with typed arrays and numpy, Temporal dates, threads, workers, asyncio, async iterators and cancellation in both directions |
| Smart card (PC/SC) | Windows, macOS, Linux | Reader enumeration, card connection, ATR and APDU exchange (winscard, PCSC.framework, libpcsclite) |
| Cryptoki (PKCS #11) | Windows verified; macOS ARM64 build included | Python-shaped PKCS #11 2.20-3.2 binding; temporary SoftHSM token, login, RSA, ECDSA, AES and SHA-256 |
| SQLite UDFs | Windows (x64/ARM64 builds included), macOS, Linux | Bundled Windows sqlite3.dll / system libsqlite3 loaded via FFI with custom JavaScript scalar UDFs (REGEXP, sha256, slugify), multi-arg aggregates (median, percentile), binary BLOBs, and NATURAL_SORT collation |
| Box2D v3 physics | Windows & Linux (x64/ARM64), macOS ARM64 builds included | Cross-platform Box2D 3.x C11 FFI binding (CLI benchmark, HTML5 Canvas SSE, raylib 60fps, and zero-dependency native OS windows via AppKit NSView/CoreGraphics, Win32 GDI+, and X11) with HFA structs, b2DebugDraw, events, and raycasts |
| Accessibility | macOS | UI automation with the Accessibility API: find elements, read and set values, press buttons, browser content |
| Controls (macOS) | macOS | A small Cocoa application through the Objective-C runtime: classes defined at runtime, menus, toolbar, tabs, file browser, date pickers, custom-drawn chart, alert, status item, light and dark appearance |
| Menu bar extra | macOS | The system tray example on macOS, same API: a status item with a menu drawn in panels (icons, toggles, nested submenus, keyboard) that never blocks Node.js: AppKit events pumped from an async loop |
| COM automation | Windows | comtypes-like vtable dispatch: shell shortcuts (IShellLinkW), Active Directory searches (IDirectorySearch) and an Active Directory explorer window (tree, objects, attributes, search) |
| Controls (Windows) | Windows | A small Win32 application: menus, toolbar, tabs, file browser, date/time, GDI chart, task dialog, notification icon, DPI-aware and themed |
| LDAP | Windows | Directory queries and changes with wldap32 (paged search, schema-aware values) |
| Registry | Windows | Read and write registry keys and values with advapi32 |
| System tray | Windows | Tray icon with a Fluent-style popup menu drawn with GDI: submenus, keyboard, per-monitor DPI |
The examples import node-ctypes by name. From a clone of this repository, build it once and run them from the repository root:
npm install && npm run build
node examples/cross-platform/python/demo_python_basics.js
From your own project, npm install node-ctypes and copy the example folder.
The Electron app has its own install/dev/build commands
and uses the local checkout as a linked dependency.
For the basics of the API (functions, structures, pointers, callbacks), see the Quick start and the guides.