Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import wNim
- import winim/lean
- const
- NOTIFY_FOR_THIS_SESSION: DWORD = 0
- WM_WTSSESSION_CHANGE: DWORD = 0x2b1
- WTS_SESSION_LOCK: DWORD = 0x7
- WTS_SESSION_UNLOCK: DWORD = 0x8
- WTS_SESSION_REMOTE_CONTROL: DWORD = 0x9
- {.push stdcall, dynlib: "wtsapi32".}
- proc WTSRegisterSessionNotification*(hwnd: HANDLE, dwFlags: DWORD): bool
- {.importc: "WTSRegisterSessionNotification".}
- proc WTSUnRegisterSessionNotification*(hwnd: HANDLE): bool
- {.importc: "WTSUnRegisterSessionNotification".}
- {.pop.}
- when isMainModule:
- let
- app = App()
- frm = Frame(title="Frame", size=(640, 480))
- sn = WTSRegisterSessionNotification(frm.getHandle, NOTIFY_FOR_THIS_SESSION)
- frm.WM_WTSSESSION_CHANGE do (ev: wEvent):
- echo ev.getWindow.handle
- case ev.getwParam
- of WTS_SESSION_LOCK: echo "lock"
- of WTS_SESSION_UNLOCK: echo "unlock"
- of WTS_SESSION_REMOTE_CONTROL: echo "remote control"
- else: echo "unknown"
- frm.center
- frm.show
- if not sn:
- echo "Error: can not register WTS Session Notification"
- else:
- defer:
- discard WTSUnRegisterSessionNotification(frm.getHandle)
- app.mainLoop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement