|
4 | 4 | ### In a nutshell:
|
5 | 5 | * Very simple and intuitive API (see [demos](./source//demos/)), with TypeScript definitions included.
|
6 | 6 | * Bundler friendly, designed with tree-shakeability in mind.
|
7 |
| - * *Not 100% tree-shakeable right now, but close. And working on it.* |
8 | 7 | * Opinionated:
|
9 |
| - * Only targets **x64** platforms (*ARM-64 may be added later, no warranty though*). |
| 8 | + * Only targets **64-bit** platforms (*Intel/AMD for now, ARM may be added later, no warranty though*). |
10 | 9 | * Only exposes **Unicode** functions and data structures (those whose name ends in `W` in the Win32 API).
|
11 | 10 | * Very easy to extend with additional functions, data structures and constants. I will add some myself time permitting; any help would be *mucho* appreciated.
|
12 | 11 |
|
|
15 | 14 |
|
16 | 15 | #### > Use the lib in your code
|
17 | 16 | 1. Install the lib in your project: `npm install libwin32`
|
18 |
| -1. Import the functions, constants and types you need. You may either import from `libwin32` or from `libwin32/<dllname>` (without the `.dll` extension). Currently, only two dlls are available: `kernel32` and `user32`. |
| 17 | +1. Import the functions and types you need. You may either import from `libwin32` or from `libwin32/<dllname>` (without the `.dll` extension) if you know which dll a function beglons to. Currently, only two dlls are available: `kernel32` and `user32`. |
| 18 | +1. (optional) Import some complementary constants. They greatly simplify calls to the Win32 API. |
| 19 | + * All constants are available via the `libwin32/consts` import. |
| 20 | + * Logically grouped constants are exported as `enum`s, where the prefix is the name of the enum. For instance, `WM_DESTROY` and `WM_KEYDOWN` are exported as `WM_.DESTROY` and `WM_.KEYDOWN`, respectively. |
19 | 21 | 1. Call the functions as instructed by the [Win32 API documentation](https://learn.microsoft.com/en-us/windows/win32/api/). All functions, constants and types are named accordingly.
|
20 |
| - * Constants like `WM_DESTROY` are exported as `enum`s, where the prefix is the name of the enum. For instance, `WM_DESTROY` and `WM_KEYDOWN` are exported as `WM.DESTROY` and `WM.KEYDOWN`, respectively. |
21 | 22 |
|
22 | 23 | ````js
|
23 |
| -import { MessageBox, MB } from 'libwin32' |
| 24 | +import { MessageBox } from 'libwin32' |
| 25 | +import { MB_ } from 'libwin32/consts' |
24 | 26 |
|
25 | 27 | const result = MessageBox(
|
26 | 28 | null,
|
27 | 29 | "Hello, world!",
|
28 | 30 | "libwin32",
|
29 |
| - MB.ICONINFORMATION | MB.YESNO |
| 31 | + MB_.ICONINFORMATION | MB_.YESNO |
30 | 32 | )
|
31 | 33 | console.dir(result)
|
32 | 34 | ````
|
@@ -121,4 +123,4 @@ None.
|
121 | 123 | * `./source/demos`:
|
122 | 124 | * Some usage examples.
|
123 | 125 | * `./source/rollup`:
|
124 |
| - * A [Rollup](https://rollup.org) plugin to ease the process of bundling this library and Koffi with your own code. See [rollup.demo.js](./rollup.demos.js) for an example of usage. |
| 126 | + * Two [Rollup](https://rollup.org) plugins to ease the process of bundling this library with your own code and to boost its tree-shakeability. See [rollup.demos.js](./rollup.demos.js) for an example of usage. |
0 commit comments