mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2026-04-18 05:23:31 +00:00
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:
56
path.go
Normal file
56
path.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user