Go调用Delphi编写的DLL
2024-10-07 17:50:54
参数整数没有问题,但是如果是字符串,要注意几个细节。
记录如下:
1.Delphi定义函数的时候,字符串参数需要使用PChar类型
2.Go传递参数的时候要将字符串转成UTF16的指针,接收的时候采用uint16的切片。
dll := syscall.MustLoadDLL("Encryptdll.dll")
defer syscall.FreeLibrary(dll.Handle)
f1 := dll.MustFindProc("test06")
fmt.Println("f1>>>>", f1) p1, _ := syscall.UTF16PtrFromString("sql")
p2 := make([]uint16, ) // pass word limited length! syscall.MAX_PATH r1, r2, err := f1.Call(uintptr(unsafe.Pointer(p1)), uintptr(unsafe.Pointer(&p2)))
if err != nil {
fmt.Println(r1, r2, p1, p2, err.Error(), syscall.UTF16ToString(p2))
}
最新文章
- B样条基函数(cubic spline basis)
- sql 优化 链接提示 查询提示 标提示
- Nodejs学习笔记(一)——初识Nodejs
- ORACLE ORA-01157: 无法标识/锁定数据文件
- 关于IE9中webdiriver使用autoit上传文件报错
- [LeetCode]题解(python):116 Populating Next Right Pointers in Each Node
- 《Java中的单例模式--两种》
- PNG图片压缩工具
- [树莓派]安装node环境
- oracle 清除当前用户的回收站
- PHP高级笔记汇总
- Spark编程进阶
- JavaSE(十一)之异常处理详解
- Lucene入门简介
- 原生JS封装 toast 弹层,自动关闭
- intellij idea 汉化
- 集合之LinkedHashMap(含JDK1.8源码分析)
- Windows两个网卡配置路由规则 同时访问内网和外网
- 问题 Duplicate entry '0' for key 'PRIMARY'
- Vim中自动在程序起始处添加版权和作者信息
热门文章
- 单点登录的实践demo
- Linux执行shell脚本的方法
- SDOI2019快速查询
- SP5971 LCMSUM 数论
- Vue与REACT两个框架的区别和优势对比
- Python中近期Pandas使用总结
- Eclipse4.9集成Tomcat 9.0.21详细版
- enable device: BAR 0 [mem 0x00000000-0x003fffff] not claimed
- Matlab Script to pre-process UAV123 tracking dataset
- BGP MPLS IP V匹N基本概念