mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-05 16:47:27 -04:00
windows: add functions for priority class
took const value from https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-setpriorityclass https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-getpriorityclass Change-Id: I376bb8e1f5de8968177512857d60169cb7b7c776 Reviewed-on: https://go-review.googlesource.com/c/sys/+/179038 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
committed by
Alex Brainman
parent
3626398d77
commit
854af27f14
@@ -196,6 +196,8 @@ var (
|
||||
procTerminateJobObject = modkernel32.NewProc("TerminateJobObject")
|
||||
procSetErrorMode = modkernel32.NewProc("SetErrorMode")
|
||||
procResumeThread = modkernel32.NewProc("ResumeThread")
|
||||
procSetPriorityClass = modkernel32.NewProc("SetPriorityClass")
|
||||
procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
|
||||
procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW")
|
||||
procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW")
|
||||
procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW")
|
||||
@@ -2105,6 +2107,31 @@ func ResumeThread(thread Handle) (ret uint32, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func SetPriorityClass(process Handle, priorityClass uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procSetPriorityClass.Addr(), 2, uintptr(process), uintptr(priorityClass), 0)
|
||||
if r1 == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetPriorityClass(process Handle) (ret uint32, err error) {
|
||||
r0, _, e1 := syscall.Syscall(procGetPriorityClass.Addr(), 1, uintptr(process), 0, 0)
|
||||
ret = uint32(r0)
|
||||
if ret == 0 {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = syscall.EINVAL
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)))
|
||||
if r1 == 0 {
|
||||
|
||||
Reference in New Issue
Block a user