Files
code-utils/machineid_windows.go
2026-08-14 07:52:01 +08:00

20 lines
463 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//go:build windows
package main
import "golang.org/x/sys/windows/registry"
// rawMachineID 读取 Windows 的 MachineGuid系统安装时生成重装才会变
func rawMachineID() string {
k, e := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Cryptography`, registry.QUERY_VALUE|registry.WOW64_64KEY)
if e != nil {
return ""
}
defer k.Close()
v, _, e := k.GetStringValue("MachineGuid")
if e != nil {
return ""
}
return v
}