Как передать структуру в ShellExecuteExA WinAPI

Хочу вызвать процесс через WinAPI с заданными параметрами, отдает 0 статус, что всё хорошо. Хотя по факту процесс не вызывает. В чем может быть проблема?

package main

import (
    "syscall"
    "unsafe"

    "golang.org/x/sys/windows"
)

var (
  shell32            = syscall.NewLazyDLL("shell32.dll")
  procShellExecuteEx = shell32.NewProc("ShellExecuteExA")
)

type ShellExecuteInfoA struct {
  cbSize       uint32
  fMask        uint32
  hwnd         uintptr
  lpVerb       *uint16
  lpFile       *uint16
  lpParameters *uint16
  lpDirectory  *uint16
  nShow        int32
}

func ShellExecute(lpFile, lpOperation, lpParameters string, fMask uint32, nShow int32) syscall.Errno {
  var f16 *uint16
  var o16 *uint16
  var p16 *uint16
  if len(lpFile) > 0 {
    f16, _ = windows.UTF16PtrFromString(lpFile)
  }
  if len(lpOperation) > 0 {
    o16, _ = windows.UTF16PtrFromString(lpOperation)
  }
  if len(lpParameters) > 0 {
    p16, _ = windows.UTF16PtrFromString(lpParameters)
  }
  s := &ShellExecuteInfoA{
    fMask:        fMask,
    hwnd:         0,
    lpVerb:       o16,
    lpFile:       f16,
    lpParameters: p16,
    lpDirectory:  nil,
    nShow:        nShow,
  }
  var err syscall.Errno
  r1, _, e1 := syscall.SyscallN(procShellExecuteEx.Addr(), uintptr(unsafe.Pointer(&s)))
  if r1 != 0 {
    err = e1
  }
  return err
}

func main() {
  err := ShellExecute("C:\\windows\\system32\\cmd.exe", "open", "", 0, 5)
  if err != 0 {
    panic(err)
  }
}

Ответы (0 шт):