package module moved into root of repository.

example in readme updated.

level pooler implemented, runs in its own goroutine.

Remote type now exported

observers example updated.
This commit is contained in:
onyx-and-iris
2022-07-09 19:01:58 +01:00
parent f16bed893f
commit 70d69f5599
32 changed files with 179 additions and 75 deletions

56
path.go Normal file
View File

@@ -0,0 +1,56 @@
package voicemeeter
import (
"errors"
"fmt"
"os"
"path/filepath"
"runtime"
"strings"
"golang.org/x/sys/windows/registry"
)
// dllPath returns the Voicemeeter installation path as a string
func dllPath() (string, error) {
if runtime.GOOS != "windows" {
return "", errors.New("only Windows OS supported")
}
var regkey string
if strings.Contains(runtime.GOARCH, "64") {
regkey = `SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall`
} else {
regkey = `SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall`
}
var vmkey = `\VB:Voicemeeter {17359A74-1236-5467}`
k, err := registry.OpenKey(registry.LOCAL_MACHINE, regkey+vmkey, registry.QUERY_VALUE)
if err != nil {
return "", errors.New("unable to access registry")
}
defer k.Close()
path, _, err := k.GetStringValue(`UninstallString`)
if err != nil {
return "", errors.New("unable to read Voicemeeter path from registry")
}
var dllName string
if strings.Contains(runtime.GOARCH, "64") {
dllName = `VoicemeeterRemote64.dll`
} else {
dllName = `VoicemeeterRemote.dll`
}
return fmt.Sprintf("%v\\%s", filepath.Dir(path), dllName), nil
}
// getDllPath is a helper function for error handling
func getDllPath() string {
path, err := dllPath()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
return path
}