读取指定地址的字符串 - ReadStringAddr
函数简介
读取指定地址的字符串。
接口名称
ReadStringAddr
DLL调用
long ReadStringAddr(long instance, long hwnd, long addr, int type, int len);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| hwnd | 长整数型 | 窗口句柄 |
| addr | 长整数型 | 地址 |
| type | 整数型 | 字符串类型(0:GBK,1:Unicode,2:UTF8) |
| len | 整数型 | 需要读取的字节数,0为自动判定 |
示例
C++
long instance = CreateCOLAPlugInterFace();
// hwnd 为目标窗口句柄
// 直接使用地址读取UTF8字符串,读取64字节
long strPtr = ReadStringAddr(instance, hwnd, 0x12345678, 2, 64);
char* str = GetStringFromPtr(strPtr);
printf("读取到的字符串: %s\n", str);
FreeStringPtr(strPtr);
Python
# 待补充
返回值
返回字符串的指针,内容为UTF-8编码。
注意事项
- 返回的字符串指针需调用 FreeStringPtr 释放内存。
