gow32

package module
v0.0.0-...-a23bf81 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2018 License: MIT Imports: 2 Imported by: 0

README

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)
}

Documentation

Index

Constants

View Source
const (
	ERROR_ALREADY_EXISTS = 183
)

Variables

This section is empty.

Functions

func CreateMutex

func CreateMutex(name string) (uintptr, error)

func ReleaseMutex

func ReleaseMutex(id uintptr) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL