mirror of
https://github.com/prometheus-community/windows_exporter
synced 2025-02-27 09:31:01 +00:00
Merge branch 'dev_cs_collector' of https://github.com/benridley/windows_exporter into dev_cs_collector
This commit is contained in:
commit
863b7d8ab4
@ -74,17 +74,19 @@ func netApiBufferFree(buffer *wKSTAInfo102) {
|
||||
|
||||
// NetWkstaGetInfo returns information about the configuration of a workstation.
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/lmwksta/nf-lmwksta-netwkstagetinfo
|
||||
func netWkstaGetInfo() (*wKSTAInfo102, uint32, error) {
|
||||
func netWkstaGetInfo() (wKSTAInfo102, uint32, error) {
|
||||
var lpwi *wKSTAInfo102
|
||||
pLevel := uintptr(102)
|
||||
|
||||
r1, _, _ := procNetWkstaGetInfo.Call(0, pLevel, uintptr(unsafe.Pointer(&lpwi)))
|
||||
defer netApiBufferFree(lpwi)
|
||||
|
||||
if ret := *(*uint32)(unsafe.Pointer(&r1)); ret != 0 {
|
||||
return nil, ret, errors.New(NetApiStatus[ret])
|
||||
return wKSTAInfo102{}, ret, errors.New(NetApiStatus[ret])
|
||||
}
|
||||
|
||||
return lpwi, 0, nil
|
||||
deref := *lpwi
|
||||
return deref, 0, nil
|
||||
}
|
||||
|
||||
// GetWorkstationInfo is an idiomatic wrapper for netWkstaGetInfo
|
||||
@ -102,7 +104,5 @@ func GetWorkstationInfo() (WorkstationInfo, error) {
|
||||
LanRoot: windows.UTF16PtrToString(info.wki102_lanroot),
|
||||
LoggedOnUsers: info.wki102_logged_on_users,
|
||||
}
|
||||
// Free the memory allocated by netapi
|
||||
netApiBufferFree(info)
|
||||
return workstationInfo, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user