使用delphi调用dll-pcshll32.dll
我需要使用delphi调用pcshll32.dll的hllapi函数。它适用于 ibm 的个人通信。我怎样才能将下面的代码更改为delphi?谢谢 !!!
EHLLAPI 入口点 (hllapi) 始终使用以下四个参数进行调用:
- EHLLAPI 函数编号(输入)
- 数据缓冲区(输入/输出)
- 缓冲区长度(输入/输出)
- 表示空间位置(输入);返回代码(输出)
IBM 标准 EHLLAPI 的原型是: [长 hllapi (LPWORD, LPSTR, LPWORD, LPWORD); IBM 增强型 EHLLAPI 的原型是: [长hllapi(LPINT,LPSTR,LPINT,LPINT);
每个参数都是通过引用而不是值传递的。因此,函数调用的每个参数都必须是指向值的指针,而不是值本身。例如,以下是调用 EHLLAPI 查询会话状态函数的正确示例:
#include "hapi_c.h"
struct HLDQuerySessionStatus QueryData;
int Func, Len, Rc;
long Rc;
memset(QueryData, 0, sizeof(QueryData)); // Init buffer
QueryData.qsst_shortname = ©A©; // Session to query
Func = HA_QUERY_SESSION_STATUS; // Function number
Len = sizeof(QueryData); // Len of buffer
Rc = 0; // Unused on input
hllapi(&Func, (char *)&QueryData, &Len, &Rc); // Call EHLLAPI
if (Rc != 0) { // Check return code
// ...Error handling
}
hllapi 调用中的所有参数都是指针,并且 EHLLAPI 函数的返回码以第 4 个参数的值返回,而不是作为的功能。
I need to call hllapi function of pcshll32.dll using delphi. It's works with personal communications of ibm. How can i change the code bellow to delphi ? Thanks !!!
The EHLLAPI entry point (hllapi) is always called with the following four parameters:
- EHLLAPI Function Number (input)
- Data Buffer (input/output)
- Buffer Length (input/output)
- Presentation Space Position (input); Return Code (output)
The prototype for IBM Standard EHLLAPI is:
[long hllapi (LPWORD, LPSTR, LPWORD, LPWORD);
The prototype for IBM Enhanced EHLLAPI is:
[long hllapi (LPINT, LPSTR, LPINT, LPINT);
Each parameter is passed by reference not by value. Thus each parameter to the function call must be a pointer to the value, not the value itself. For example, the following is a correct example of calling the EHLLAPI Query Session Status function:
#include "hapi_c.h"
struct HLDQuerySessionStatus QueryData;
int Func, Len, Rc;
long Rc;
memset(QueryData, 0, sizeof(QueryData)); // Init buffer
QueryData.qsst_shortname = ©A©; // Session to query
Func = HA_QUERY_SESSION_STATUS; // Function number
Len = sizeof(QueryData); // Len of buffer
Rc = 0; // Unused on input
hllapi(&Func, (char *)&QueryData, &Len, &Rc); // Call EHLLAPI
if (Rc != 0) { // Check return code
// ...Error handling
}
All the parameters in the hllapi call are pointers and the return code of the EHLLAPI function is returned in the value of the 4th parameter, not as the value of the function.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要首先将 hapi_c.h 转换为 Delphi(如果您以前从未这样做过,您可能想从这里开始阅读:Rudy 的 Delphi 角:转换的陷阱
You need to convert hapi_c.h to Delphi first (if you have never done that before you might want to start reading here: Rudy's Delphi Corner: Pitfalls of Converting