delphi - 从 delphi 或 lazarus 调用 Visual Studio dll
问题描述
我需要从 delphi 7 或 lazarus 调用一个 dll。关于 dll 的信息很少,但我有一个在 Visual Studio 中使用的示例:声明:
[DllImport("landwell.dll", EntryPoint = "PTcomm", CharSet = CharSet.Auto)]
public static extern int PTcomm(int com, int boud, ref int Rcount);
[DllImport("landwell.dll", EntryPoint = "PTcomm_YPWJ", CharSet = CharSet.Auto)]
public static extern int PTcomm_YPWJ(int com, int boud, ref int Rcount);
[DllImport("landwell.dll", EntryPoint = "PTrecord", CharSet = CharSet.Auto)]
public static extern int PTrecord(int num,byte[] record);
如何在 Delphi 7 或 Lazarus 中声明和调用这些函数?
我唯一的文档是: 1、Common Transmit: PTcomm(int com,int boud,int *Rcount) Com是串口号,boud rate是9600,*Rcount是记录总数
“1”表示返回成功, “0”表示无记录,“-1”表示打开端口不成功,“-2”表示发送不成功
2、常用采集数据 PTrecord(int num,byte record[8]) record{8} 表示8byte(包括读卡器号),num 表示序列号 “1”表示返回成功,“0”表示返回不成功我只有Visual Studio 中的一个示例,我什至无法尝试,因为它是用旧版本的 VS 编写的,并且自动转换不起作用。这时候我没有学习VS的打算。文章前面提到的声明来自那个例子。有人指责我什至没有尝试过,他们不认识我,也不知道我做了什么。我尝试过但失败了,这就是我要问的原因。
谢谢,让-克劳德
解决方案
在 Delphi 和 Lazarus 中尝试这些声明:
function PTcomm(com, boud: Integer; var Rcount: Integer): Integer; stdcall; external 'landwell.dll';
function PTcomm_YPWJ(com, boud: Integer; var Rcount: Integer): Integer; stdcall; external 'landwell.dll';
function PTrecord(num: Integer; rec: PByte): Integer; stdcall; external 'landwell.dll';
推荐阅读
- matlab - 在MATLAB中将高斯曲线拟合到直方图
- javascript - Axios ReactJs Laravel:如何检索多个请求 Api
- python - Django,ModelFormField:多次使用评估的查询集
- python - Python:如何仅从 Outlook 中获取电子邮件中的最新消息
- react-native - React Native - 从 Facebook 个人资料下载图片?
- c# - Foreach 中的 Foreach 同时迭代
- javascript - 如何最好地将 JSON 子数据对象数组重组为父数组
- android - 使 RatingBar 辅助颜色不透明
- ios - urlsession如何确定何时下载所有文件
- sql - SQL While 循环存在