Skip to content

bbigras/go-windows-session-notifications

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

go-windows-session-notifications

Receive session change notifications from Windows.

Sample code

package main

import (
	"github.com/brunoqc/go-windows-session-notifications"
	"log"
)

func main() {
	quit := make(chan int)

	changes := make(chan int, 100)
	closeChan := make(chan int)

	go func() {
		for {
			select {
			case c := <-changes:
				switch c {
				case session_notifications.WTS_SESSION_LOCK:
					log.Println("session locked")
				case session_notifications.WTS_SESSION_UNLOCK:
					log.Println("session unlocked")
				}
				close(m.ChanOk)
			}
		}
	}()

	session_notifications.Subscribe(changes, closeChan)

	// ctrl+c to quit
	<-quit
}

Build with

set CGO_LDFLAGS=-lwtsapi32

# with powershell
$env:CGO_LDFLAGS="-lwtsapi32";

go build

About

Receive session notifications on Windows

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published