gowin

package
v0.0.0-...-8b1022e Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2016 License: Apache-2.0, GPL-2.0 Imports: 5 Imported by: 0

README

gowin

Provide simple Windows OS interface to manipulate windows registry, environment variables, default paths and windows services from Golang lenguaje

###How to use it

	go get github.com/luisiturrios/gowin
	import "github.com/luisiturrios/gowin"

###Example write, read, remove windows registry key

    //	Write string on the registry require admin privileges
	err = gowin.WriteStringReg("HKLM",`Software\iturrios\gowin`,"value","Hello world")
	if err != nil {
		log.Println(err)
	}else{
		fmt.Println("Key inserted")
	}
	//	write uint32 on the registry require admin privileges
	err = gowin.WriteDwordReg("HKLM",`Software\iturrios\gowin`,"value2", 4294967295)
	if err != nil {
		log.Println(err)
	}else{
		fmt.Println("Key inserted")
	}
	//get reg
	val, err := gowin.GetReg("HKLM", `Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders`, "Common AppData")
	if err != nil {
		log.Println(err)
	}
	fmt.Printf(val)
    // remove key
	err = gowin.DeleteKey("HKLM",`Software\iturrios`,"gowin")
	if err != nil {
		log.Println(err)
	}else{
		fmt.Println("Key Removed")
	}


###Example Read windows ShellFolders

	folders := gowin.ShellFolders{gowin.ALL}
	//	Or 
	folder := new(gowin.ShellFolders)

	//Read ProgramFiles
	fmt.Println(folders.ProgramFiles())
	
	//Read all user AppData
	folders.Context = gowin.ALL
	fmt.Println(folders.AppData())
	
	//Read Current user AppData
	folders.Context = gowin.USER
	fmt.Println(folders.AppData())

	// functions
	folders.ProgramFiles()
	folders.AppData()
	folders.Desktop()
	folders.Documents()
	folders.StartMenu()
	folders.StartMenuPrograms()

###Example Read windows environment variables

    // Get environment var
	goroot := gowin.GetEnvVar("GOROOT")
	fmt.Printf("GORROT: %s\n", goroot)
	// Write environment var
	err := gowin.WriteEnvVar("TVAR","hello word")
	if err != nil {
		log.Println(err)
	}

###Donation

If you appreciate the work in this repo and like the continue development donate to this paypal account luisiturrios@me.com Thanks

Documentation

Overview

Provide simple Windows OS interface to manipulate windows registry, environment variables, default paths and windows services from Golang lenguaje

Index

Constants

View Source
const (
	ALL  = true  //Use for make ShellFolders.Context
	USER = false //Use for make ShellFolders.Context
)

Variables

This section is empty.

Functions

func DeleteKey

func DeleteKey(hkey, path, name string) (err error)

Use to remove key from windows registry the HKEY in the next definition HHLM, HKCU, HKCC, HKCR, HKU

func GetEnvVar

func GetEnvVar(name string) (val string)

Use to read value from windows environment variables by name

func GetReg

func GetReg(hkey, path, name string) (val string, err error)

func GetRegRaw

func GetRegRaw(hkey, path, name string) (val []uint16, err error)

TODO: Solve error in query DWORD registry Use to read value from windows registry the HKEY in the next definition HKLM, HKCU, HKCC, HKCR, HKU

func WriteDwordReg

func WriteDwordReg(hkey, path, name string, val uint32) (err error)

Use to write uint32 value to windows registry the HKEY in the next definition HHLM, HKCU, HKCC, HKCR, HKU

func WriteEnvVar

func WriteEnvVar(name, val string) (err error)

Use to write value on windows environment variable by name

func WriteStringReg

func WriteStringReg(hkey, path, name, val string) (err error)

Use to write string value to windows registry the HKEY in the next definition HHLM, HKCU, HKCC, HKCR, HKU

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

type ShellFolders

type ShellFolders struct {
	Context bool
}

func (*ShellFolders) AppData

func (s *ShellFolders) AppData() (val string)

Return string with AppData path, its use the Context defined in the ShellFolders struct

func (*ShellFolders) Desktop

func (s *ShellFolders) Desktop() (val string)

Return string with Desktop path, its use the Context defined in the ShellFolders struct

func (*ShellFolders) Documents

func (s *ShellFolders) Documents() (val string)

Return string with Documents path, its use the Context defined in the ShellFolders struct

func (*ShellFolders) ProgramFiles

func (s *ShellFolders) ProgramFiles() (val string)

Return string with ProgramFiles path Its don't use the Context value

func (*ShellFolders) StartMenu

func (s *ShellFolders) StartMenu() (val string)

Return string with StarMenu root path, its use the Context defined in the ShellFolders struct

func (*ShellFolders) StartMenuPrograms

func (s *ShellFolders) StartMenuPrograms() (val string)

Return string with StarMenu programs path, its use the Context defined in the ShellFolders struct

Jump to

Keyboard shortcuts

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