c中的结构体该怎么转换。。。。。。。。

mandarin 2010-07-15 09:20:21
typedef struct _CallBackFunction
{
int (__cdecl *OnUserLogin)(int iEventType, const char* UserName);

int (__cdecl *OnUserLogout)(int iEventType, const char* UserName);

}CallBackFunction;

要开发一个接口,他提供的是。h的文件,现在想把它转换成pas的用delphi开发,但是上面这种结构体中带函数申明的改怎么弄啊,哪位大佬知道额。。。
...全文
120 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
sanguomi 2010-07-15
  • 打赏
  • 举报
回复
C++ 调用


#include <stdio.h>
#include <iostream>
using namespace std;

typedef struct _CallBackFunction
{
int (__cdecl *OnUserLogin)(int iEventType, const char* UserName);

int (__cdecl *OnUserLogout)(int iEventType, const char* UserName);

}CallBackFunction;

int UserLogin(int iEventType, const char* UserName)
{
cout<<UserName<<endl;
return 0;
}

int main()
{
CallBackFunction a;
a.OnUserLogin = UserLogin;
a.OnUserLogin(2, "test");
return 0;
}

sanguomi 2010-07-15
  • 打赏
  • 举报
回复
type
OnUserLogin = function(iEventType: Integer; const UserName: Pchar) :Integer; cdecl;

type
_CallBackFunction = record
UserLogin: OnUserLogin;
UserLogout: OnUserLogin;
end;
CallBackFunction = _CallBackFunction;

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧