github.com/ckxng/wakeup@v0.0.0-20190105202853-90356a5f5a15/src/wingui/zwinapi.go (about)

     1  // +build windows
     2  // mksyscall_windows.pl winapi.go
     3  // MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
     4  
     5  package wingui
     6  
     7  import "unsafe"
     8  import "syscall"
     9  
    10  var (
    11      modkernel32 = syscall.NewLazyDLL("kernel32.dll")
    12      moduser32   = syscall.NewLazyDLL("user32.dll")
    13  
    14      procGetModuleHandleW = modkernel32.NewProc("GetModuleHandleW")
    15      procRegisterClassExW = moduser32.NewProc("RegisterClassExW")
    16      procCreateWindowExW  = moduser32.NewProc("CreateWindowExW")
    17      procDefWindowProcW   = moduser32.NewProc("DefWindowProcW")
    18      procDestroyWindow    = moduser32.NewProc("DestroyWindow")
    19      procPostQuitMessage  = moduser32.NewProc("PostQuitMessage")
    20      procShowWindow       = moduser32.NewProc("ShowWindow")
    21      procUpdateWindow     = moduser32.NewProc("UpdateWindow")
    22      procGetMessageW      = moduser32.NewProc("GetMessageW")
    23      procTranslateMessage = moduser32.NewProc("TranslateMessage")
    24      procDispatchMessageW = moduser32.NewProc("DispatchMessageW")
    25      procLoadIconW        = moduser32.NewProc("LoadIconW")
    26      procLoadCursorW      = moduser32.NewProc("LoadCursorW")
    27      procSetCursor        = moduser32.NewProc("SetCursor")
    28      procSendMessageW     = moduser32.NewProc("SendMessageW")
    29      procPostMessageW     = moduser32.NewProc("PostMessageW")
    30  )
    31  
    32  func GetModuleHandle(modname *uint16) (handle syscall.Handle, err error) {
    33      r0, _, e1 := syscall.Syscall(procGetModuleHandleW.Addr(), 1, uintptr(unsafe.Pointer(modname)), 0, 0)
    34      handle = syscall.Handle(r0)
    35      if handle == 0 {
    36          if e1 != 0 {
    37              err = error(e1)
    38          } else {
    39              err = syscall.EINVAL
    40          }
    41      }
    42      return
    43  }
    44  
    45  func RegisterClassEx(wndclass *Wndclassex) (atom uint16, err error) {
    46      r0, _, e1 := syscall.Syscall(procRegisterClassExW.Addr(), 1, uintptr(unsafe.Pointer(wndclass)), 0, 0)
    47      atom = uint16(r0)
    48      if atom == 0 {
    49          if e1 != 0 {
    50              err = error(e1)
    51          } else {
    52              err = syscall.EINVAL
    53          }
    54      }
    55      return
    56  }
    57  
    58  func CreateWindowEx(exstyle uint32, classname *uint16, windowname *uint16, style uint32, x int32, y int32, width int32, height int32, wndparent syscall.Handle, menu syscall.Handle, instance syscall.Handle, param uintptr) (hwnd syscall.Handle, err error) {
    59      r0, _, e1 := syscall.Syscall12(procCreateWindowExW.Addr(), 12, uintptr(exstyle), uintptr(unsafe.Pointer(classname)), uintptr(unsafe.Pointer(windowname)), uintptr(style), uintptr(x), uintptr(y), uintptr(width), uintptr(height), uintptr(wndparent), uintptr(menu), uintptr(instance), uintptr(param))
    60      hwnd = syscall.Handle(r0)
    61      if hwnd == 0 {
    62          if e1 != 0 {
    63              err = error(e1)
    64          } else {
    65              err = syscall.EINVAL
    66          }
    67      }
    68      return
    69  }
    70  
    71  func DefWindowProc(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (lresult uintptr) {
    72      r0, _, _ := syscall.Syscall6(procDefWindowProcW.Addr(), 4, uintptr(hwnd), uintptr(msg), uintptr(wparam), uintptr(lparam), 0, 0)
    73      lresult = uintptr(r0)
    74      return
    75  }
    76  
    77  func DestroyWindow(hwnd syscall.Handle) (err error) {
    78      r1, _, e1 := syscall.Syscall(procDestroyWindow.Addr(), 1, uintptr(hwnd), 0, 0)
    79      if int(r1) == 0 {
    80          if e1 != 0 {
    81              err = error(e1)
    82          } else {
    83              err = syscall.EINVAL
    84          }
    85      }
    86      return
    87  }
    88  
    89  func PostQuitMessage(exitcode int32) {
    90      syscall.Syscall(procPostQuitMessage.Addr(), 1, uintptr(exitcode), 0, 0)
    91      return
    92  }
    93  
    94  func ShowWindow(hwnd syscall.Handle, cmdshow int32) (wasvisible bool) {
    95      r0, _, _ := syscall.Syscall(procShowWindow.Addr(), 2, uintptr(hwnd), uintptr(cmdshow), 0)
    96      wasvisible = bool(r0 != 0)
    97      return
    98  }
    99  
   100  func UpdateWindow(hwnd syscall.Handle) (err error) {
   101      r1, _, e1 := syscall.Syscall(procUpdateWindow.Addr(), 1, uintptr(hwnd), 0, 0)
   102      if int(r1) == 0 {
   103          if e1 != 0 {
   104              err = error(e1)
   105          } else {
   106              err = syscall.EINVAL
   107          }
   108      }
   109      return
   110  }
   111  
   112  func GetMessage(msg *Msg, hwnd syscall.Handle, MsgFilterMin uint32, MsgFilterMax uint32) (ret int32, err error) {
   113      r0, _, e1 := syscall.Syscall6(procGetMessageW.Addr(), 4, uintptr(unsafe.Pointer(msg)), uintptr(hwnd), uintptr(MsgFilterMin), uintptr(MsgFilterMax), 0, 0)
   114      ret = int32(r0)
   115      if ret == -1 {
   116          if e1 != 0 {
   117              err = error(e1)
   118          } else {
   119              err = syscall.EINVAL
   120          }
   121      }
   122      return
   123  }
   124  
   125  func TranslateMessage(msg *Msg) (done bool) {
   126      r0, _, _ := syscall.Syscall(procTranslateMessage.Addr(), 1, uintptr(unsafe.Pointer(msg)), 0, 0)
   127      done = bool(r0 != 0)
   128      return
   129  }
   130  
   131  func DispatchMessage(msg *Msg) (ret int32) {
   132      r0, _, _ := syscall.Syscall(procDispatchMessageW.Addr(), 1, uintptr(unsafe.Pointer(msg)), 0, 0)
   133      ret = int32(r0)
   134      return
   135  }
   136  
   137  func LoadIcon(instance syscall.Handle, iconname *uint16) (icon syscall.Handle, err error) {
   138      r0, _, e1 := syscall.Syscall(procLoadIconW.Addr(), 2, uintptr(instance), uintptr(unsafe.Pointer(iconname)), 0)
   139      icon = syscall.Handle(r0)
   140      if icon == 0 {
   141          if e1 != 0 {
   142              err = error(e1)
   143          } else {
   144              err = syscall.EINVAL
   145          }
   146      }
   147      return
   148  }
   149  
   150  func LoadCursor(instance syscall.Handle, cursorname *uint16) (cursor syscall.Handle, err error) {
   151      r0, _, e1 := syscall.Syscall(procLoadCursorW.Addr(), 2, uintptr(instance), uintptr(unsafe.Pointer(cursorname)), 0)
   152      cursor = syscall.Handle(r0)
   153      if cursor == 0 {
   154          if e1 != 0 {
   155              err = error(e1)
   156          } else {
   157              err = syscall.EINVAL
   158          }
   159      }
   160      return
   161  }
   162  
   163  func SetCursor(cursor syscall.Handle) (precursor syscall.Handle, err error) {
   164      r0, _, e1 := syscall.Syscall(procSetCursor.Addr(), 1, uintptr(cursor), 0, 0)
   165      precursor = syscall.Handle(r0)
   166      if precursor == 0 {
   167          if e1 != 0 {
   168              err = error(e1)
   169          } else {
   170              err = syscall.EINVAL
   171          }
   172      }
   173      return
   174  }
   175  
   176  func SendMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (lresult uintptr) {
   177      r0, _, _ := syscall.Syscall6(procSendMessageW.Addr(), 4, uintptr(hwnd), uintptr(msg), uintptr(wparam), uintptr(lparam), 0, 0)
   178      lresult = uintptr(r0)
   179      return
   180  }
   181  
   182  func PostMessage(hwnd syscall.Handle, msg uint32, wparam uintptr, lparam uintptr) (err error) {
   183      r1, _, e1 := syscall.Syscall6(procPostMessageW.Addr(), 4, uintptr(hwnd), uintptr(msg), uintptr(wparam), uintptr(lparam), 0, 0)
   184      if int(r1) == 0 {
   185          if e1 != 0 {
   186              err = error(e1)
   187          } else {
   188              err = syscall.EINVAL
   189          }
   190      }
   191      return
   192  }