psapi.go 579 B

123456789101112131415161718192021222324252627
  1. // Copyright 2010-2012 The W32 Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build windows
  5. package w32
  6. import (
  7. "syscall"
  8. "unsafe"
  9. )
  10. var (
  11. modpsapi = syscall.NewLazyDLL("psapi.dll")
  12. procEnumProcesses = modpsapi.NewProc("EnumProcesses")
  13. )
  14. func EnumProcesses(processIds []uint32, cb uint32, bytesReturned *uint32) bool {
  15. ret, _, _ := procEnumProcesses.Call(
  16. uintptr(unsafe.Pointer(&processIds[0])),
  17. uintptr(cb),
  18. uintptr(unsafe.Pointer(bytesReturned)))
  19. return ret != 0
  20. }