mirror of
https://github.com/prometheus-community/windows_exporter
synced 2025-02-17 12:37:30 +00:00
29 lines
457 B
Go
29 lines
457 B
Go
package testutils
|
|
|
|
import (
|
|
"unsafe"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
var (
|
|
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
|
|
|
procGetProcessHandleCount = modkernel32.NewProc("GetProcessHandleCount")
|
|
)
|
|
|
|
func GetProcessHandleCount(handle windows.Handle) (uint32, error) {
|
|
var count uint32
|
|
|
|
r1, _, err := procGetProcessHandleCount.Call(
|
|
uintptr(handle),
|
|
uintptr(unsafe.Pointer(&count)),
|
|
)
|
|
|
|
if r1 != 1 {
|
|
return 0, err
|
|
}
|
|
|
|
return count, nil
|
|
}
|