返回顶部

收藏

Google Go语言调用window api函数执行程序

更多

Google Go语言通过syscall,unsafe模块访问windows api,ShellExecute

[Google Go]代码

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:\\Program Files\\TTPlayer\\TTPlayer.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);
}

标签:Go

收藏

0人收藏

支持

0

反对

0

发表评论