waitingsong / node-win32-api

win32 api
MIT License
440 stars 56 forks source link

Add GenerateConsoleCtrlEvent() #28

Closed zenflow closed 3 years ago

zenflow commented 4 years ago

Adds GenerateConsoleCtrlEvent to the Kernel32 library. This is useful for sending ctrl+c signal to all processes attached to the current console, causing their SIGINT event handlers to fire, causing them to exit gracefully (i.e. after cleaning up if necessary). Some related discussion: https://github.com/nodejs/node/issues/35172#issuecomment-691624790

In the linked documentation (under "Parameters") we see that the dwCtrlEvent parameter uses an enumeration:

Is there some way we should include this enumeration in this library?

For now it is possible to just use the number value.

/cc @waitingsong and thanks for the awesome library ❤️

waitingsong commented 3 years ago

Hi, you can add constans of knl32 here : https://github.com/waitingsong/node-win32-api/blob/master/packages/win32-api/src/lib/kernel32/constants.ts