c结构体转ahk结构
VS编译时打印指定的结构体的内存布局
/d1reportSingleClassLayoutMY_STRUCT
cpp代码
#include <string>
#include <iostream>
using namespace std;
typedef struct MY_STRUCT
{
int a;
double b;
char str[128];
}MY_STRUCT;
typedef struct MY_OUT_STRUCT
{
int a;
double b;
char str[128];
}MY_OUT_STRUCT;
extern "C" _declspec(dllexport) int cpp2ahk(MY_STRUCT *in_struct, MY_OUT_STRUCT *out_struct)
{
cout << in_struct->a << in_struct->b << in_struct->str << endl;
out_struct->a = 10;
out_struct->b = 9.9;
sprintf_s(out_struct->str, "%s", "autohoktey");
return 0;
}
ahk v2测试代码
#include <log4ahk>
MyStruct := Buffer(144, 0)
NumPut("UInt", 100, MyStruct, 0)
NumPut("Double", 9.99, MyStruct, 8)
str := "autohotkey_#!#@^%%"
StrPut(str, MyStruct.Ptr + 16, "UTF-8")
DllCall("stltest\cpp2ahk", "Ptr", MyStruct, "Ptr", MyStruct)
a := NumGet(MyStruct, 0, "Int")
b := NumGet(MyStruct, 8, "double")
str := StrGet(MyStruct.Ptr + 16, 128, "UTF-8")
log.info(a)
log.info(b)
log.info(str)
图片有点问题呀
github的链接,不稳定
可以把图片上传到社区