Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.
/ gow32 Public archive
forked from rodolfoag/gow32

Windows APIs for Golang

License

Notifications You must be signed in to change notification settings

gytpol/gow32

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gow32

Windows APIs for Golang

CreateMutex: creates a mutex object on Windows. Usefull for ensuring that only one instance of the application is open. CreateMutex will return the error ERROR_ALREADY_EXISTS ( int(err.(syscall.Errno)) ) if the mutex was already created by another program.


package main

import (
	"bufio"
	"fmt"
	"github.com/rodolfoag/gow32"
	"os"
	"syscall"
)

func main() {
	m := os.Args[1]
	_, err := gow32.CreateMutex(m)
	if err != nil {
		fmt.Printf("Error: %d - %s\n", int(err.(syscall.Errno)), err.Error())
	} else {
		fmt.Printf("Mutex %s create. Press enter to quit.\n", m)
		bufio.NewReader(os.Stdin).ReadBytes('\n')
	}

	defer gow32.ReleaseMutex(mutexId)
}

About

Windows APIs for Golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%