win32-def
Definitions of Windows Date Types for node-ffi, node-ffi-napi
What can I do with this?
Write node-ffi or node-ffi-napi calling win32 native functions code by Typescript with Types support.
Installing
npm install win32-def
Usage
import * as ffi from 'ffi'
import { DModel as M, DTypes as W, FModel as FM } from 'win32-def'
export interface Win32Fns extends FM.DllFuncsModel {
ClientToScreen(hWnd: M.HWND, lpPoint: M.LPPOINT): M.BOOL
GetAncestor(hwnd: M.HWND, gaFlags: M.UINT): M.HWND
}
export const user32: Win32Fns = ffi.Library('user32.dll', {
ClientToScreen: [W.BOOL, [W.HWND, W.LPPOINT] ],
GetAncestor: [W.HWND, [W.HWND, W.UINT] ],
})
import * as Struct from 'ref-struct'
import { DModel as M, DStruct as DS } from 'win32-api'
const point = new Struct(DS.POINT)()
const point: M.POINT_Struct = new Struct(DS.POINT)()
point.x = 100
point.y = 200
console.log(point)
import * as ref from 'ref-napi'
import * as StructDi from 'ref-struct-di'
import { DModel as M, DStruct as DS } from 'win32-api'
const Struct = StructDi(ref)
const point: M.POINT_Struct = new Struct(DS.POINT)()
point.x = 100
point.y = 200
console.log(point)
import * as ref from 'ref'
import { K } from 'win32-api'
import { FModel as FM, DTypes as W } from 'win32-def'
const knl32 = K.load()
const buf = <FM.Buffer> Buffer.alloc(4)
buf.writeInt32LE(12345, 0)
const hInstance = <FM.Buffer> ref.alloc(W.HINSTANCE)
knl32.GetModuleHandleExW(0, null, hInstance)
Relevant
License
MIT
Languages