Files
rpi5-health/internal/windows_system/win.go
T
2026-10-05 18:19:36 +02:00

37 lines
903 B
Go

//go:build windows
package windows_system
import (
"sync"
"golang.org/x/sys/windows"
)
type WindowsSystemCheckTools struct {
/*
* Win32 API
*/
Kernel32 *windows.LazyDLL
/*
* Windows memory information
*/
ProcGlobalMemoryStatusEx *windows.LazyProc
/*
* Windows processor information
*/
SystemTimes *windows.LazyProc
}
func GetWindowsTools() WindowsSystemCheckTools {
kernel32 := sync.OnceValue(func() *windows.LazyDLL { return windows.NewLazySystemDLL("kernel32.dll") })
procGlobalMemoryStatusEx := sync.OnceValue(func() *windows.LazyProc { return kernel32().NewProc("GlobalMemoryStatusEx") })
systemTimes := sync.OnceValue(func() *windows.LazyProc { return kernel32().NewProc("GetSystemTimes") })
return WindowsSystemCheckTools{
Kernel32: kernel32(),
ProcGlobalMemoryStatusEx: procGlobalMemoryStatusEx(),
SystemTimes: systemTimes(),
}
}