golang ---调用window api函数执行程序

package main

import "syscall"
import "unsafe"

func main() {
	var hand uintptr = uintptr(0)
	var operator uintptr = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr("open")))
	var fpath uintptr = uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr("D:\\GOPATH\\src\\data.go\\data.go.exe")))
	var param uintptr = uintptr(0)
	var dirpath uintptr = uintptr(0)
	var ncmd uintptr = uintptr(1)
	shell32 := syscall.NewLazyDLL("shell32.dll")
	ShellExecuteW := shell32.NewProc("ShellExecuteW")
	_, _, _ = ShellExecuteW.Call(hand, operator, fpath, param, dirpath, ncmd)
}

  

posted on 2019-07-02 11:11  清明-心若淡定  阅读(1442)  评论(0编辑  收藏  举报