mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-31 06:16:41 -04:00
windows: add GenerateConsoleCtrlEvent function
ref: https://docs.microsoft.com/en-us/windows/console/generateconsolectrlevent Change-Id: Id5db1d4c7d73a142405061353f578b1be93dbbb9 Reviewed-on: https://go-review.googlesource.com/c/sys/+/179538 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
6a60838ec2
commit
95d888ea44
@@ -261,6 +261,7 @@ func NewCallbackCDecl(fn interface{}) uintptr {
|
|||||||
//sys SetPriorityClass(process Handle, priorityClass uint32) (err error) = kernel32.SetPriorityClass
|
//sys SetPriorityClass(process Handle, priorityClass uint32) (err error) = kernel32.SetPriorityClass
|
||||||
//sys GetPriorityClass(process Handle) (ret uint32, err error) = kernel32.GetPriorityClass
|
//sys GetPriorityClass(process Handle) (ret uint32, err error) = kernel32.GetPriorityClass
|
||||||
//sys SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error)
|
//sys SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error)
|
||||||
|
//sys GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error)
|
||||||
|
|
||||||
// Volume Management Functions
|
// Volume Management Functions
|
||||||
//sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW
|
//sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ var (
|
|||||||
procSetPriorityClass = modkernel32.NewProc("SetPriorityClass")
|
procSetPriorityClass = modkernel32.NewProc("SetPriorityClass")
|
||||||
procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
|
procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
|
||||||
procSetInformationJobObject = modkernel32.NewProc("SetInformationJobObject")
|
procSetInformationJobObject = modkernel32.NewProc("SetInformationJobObject")
|
||||||
|
procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent")
|
||||||
procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW")
|
procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW")
|
||||||
procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW")
|
procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW")
|
||||||
procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW")
|
procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW")
|
||||||
@@ -2146,6 +2147,18 @@ func SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobOb
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error) {
|
||||||
|
r1, _, e1 := syscall.Syscall(procGenerateConsoleCtrlEvent.Addr(), 2, uintptr(ctrlEvent), uintptr(processGroupID), 0)
|
||||||
|
if r1 == 0 {
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
} else {
|
||||||
|
err = syscall.EINVAL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) {
|
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)))
|
r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)))
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user