美文网首页
Go 调用dll

Go 调用dll

作者: tpkeeper | 来源:发表于2017-03-28 17:21 被阅读622次

运行结果

go代码

package main

import (
    "fmt"
    "syscall"
    "unsafe"
)

func main() {
    test := syscall.NewLazyDLL("Win32Project1.dll")
    add := test.NewProc("add")
    outRand := make([]byte, 2)
    a := 1
    b := 2
    sum, _, _ := add.Call(uintptr(a), uintptr(b), uintptr(unsafe.Pointer(&outRand[0])))
    fmt.Printf("sum:%d\noutRand:%s\n", sum, outRand)
}

c++代码(.cpp)

#include "Win32Project1.h"
#include "stdafx.h"

int _stdcall add(int a, int b,char* c) {
    *c ='e' ;
    *(c + 1) = 't';
    return a + b;
}

c++代码(.h)

extern _declspec(dllexport) int _stdcall add(int a,int b);

c++代码(.def)

LIBRARY Win32Project1
EXPORTS
add @ 1

相关文章

  • GO 调用 DLL 类库

    最近一个项目需要用到Go调用C++的DLL类库 这里记录一下坑 DLL 原型 GO调用DLL 执行结果 坑 一开始...

  • Go 调用dll

    运行结果 go代码 c++代码(.cpp) c++代码(.h) c++代码(.def)

  • go编译dll给python调用

    go 编译成dll动态库 将生成的dll拷贝到python目录下 python调用代码

  • [NodeJs] 调用Go dll文件

    GO 步骤 设置编译环境为64位 GOARCH=amd64 ,如果想设置为32位 GOARCH=386需要生成动态...

  • C# 结合 Golang 开发

    1. 实现方式与语法形式 基本方式:将 Go 程序编译成 DLL 供 C# 调用。 1.1 Go代码 注意:代码中...

  • Qt 中调用 LIB 、DLL 等

    Qt 中调用 LIB 、DLL 等 标签(空格分隔): Qt&C++ lib、dll 的调用分为隐式调用和显式调用...

  • 调用DLL

    设置输入输出参数:

  • DLL调用

    使用VS2012生成DLL文件(1)在C++中调用DLL中的函数(2)在C++中调用DLL中的函数(3)在VS20...

  • 调用dll

  • python使用ctypes调用dll

    因为 ctypes 是内置模块,可以直接使用: 加载dll程序 调用dll方法 直接调用: 传递 数字 参数: 传...

网友评论

      本文标题:Go 调用dll

      本文链接:https://www.haomeiwen.com/subject/mmajottx.html