请大侠出手将下列VC++语句转换为Delphi语句,300分奉上,不够另加 ( 积分: 200 )

  • 主题发起人 主题发起人 huayan889
  • 开始时间 开始时间
H

huayan889

Unregistered / Unconfirmed
GUEST, unregistred user!
哪位大侠出手将下列VC++的语句转换为Delphi语句,300分奉上,不够另加,在线急等。

1.
typedef Void (*EsrFunc)(unsigned long esrParam);

typedef struct
{
char m_s8ServerIp[32]

unsigned long m_u32ServerPort

char m_s8UserName[32]

char m_s8UserPwd[32]

}ServerID_t;

typedef struct
{
unsigned long m_u32DataSize

}PrivateData_t;

//以上两段定义是为了表述在下面函数中的ServerID_T及PrivateData_t,可以不用转换。

int WINAPI XMS_acsOpenStream(unsigned long * acsHandle,ServerID_t *serverID,DJ_U8 u8AppID, PrivateData_t * privateData);

int WINAPI XMS_acsSetESR(unsigned long acsHandle,EsrFunc esr,unsigned long esrParam,BOOL notifyAll);


2.
#define FetchEventData(pAcsEvt) ((char *)pAcsEvt + sizeof(Acs_Evt_t))
#define FetchDeviceList(pAcsEvt) ((char *)FetchEventData(pAcsEvt) + sizeof(Acs_Dev_List_Head_t))

3.
typedef struct
{
unsigned char m_u8PkgExtend;
unsigned int m_u16DataLen;

struct ITP_GUID_tag
{
unsigned char m_u8ModuleType

unsigned char m_u8MainFuncId

}ITP_GUID;

unsigned int m_u16Reserve


}PKG_HEAD_STRUCT, *PPKG_HEAD_STRUCT;

Long ITP_Msg_AttachData(PPKG_HEAD_STRUCT *ppPkgHead,unsigned char *u8pData, long s32DataLen);

4.
typedef Long (*PTIMERFUNC)(Long *);

typedef struct _tagITP_FLOW_INFO ITP_FLOW_INFO,*PITP_FLOW_INFO;
typedef struct _tagITP_FLOW_CHAN ITP_FLOW_CHAN,*PITP_FLOW_CHAN;
typedef struct _tagITP_RES_CHAN ITP_RES_CHAN, *PITP_RES_CHAN;
typedef struct _tagITP_FLOW_TIMER ITP_FLOW_TIMER, *PITP_FLOW_TIMER;

typedef struct _tagITP_FLOW_INFO
{
unsigned char m_s8FlowName[ITP_FLOW_MAX_FLOWNAME_LEN]

unsigned Long* m_hdlDllFunc[ITP_MAX_DLLFUNC_NUM]

PITP_FLOW_CHAN *m_PITPFlowChan

}ITP_FLOW_INFO,*PITP_FLOW_INFO;

typedef struct _tagITP_FLOW_CHAN
{
PITP_FLOW_INFO m_PITPFlowInfo

PITP_RES_CHAN m_PITPResList[ITP_MAX_BINDRES_NUM];
PITP_FLOW_TIMER m_PITPTimerChan[ITP_MAX_BINDTIMER_NUM];
unsigned char *m_PITPFlowExtData

unsigned char *m_PITPPublicBuf

}ITP_FLOW_CHAN,*PITP_FLOW_CHAN;

typedef struct _tagITP_RES_CHAN
{
unsigned char m_u8UnitIndex

Char m_s8InfoBuf[ITP_FLOW_SHOW_INFO_NUM][ITP_FLOW_SHOW_INFO_SIZE];
}ITP_RES_CHAN,*PITP_RES_CHAN;
//下面这段定义起描述作用,可以不用转换
typedef struct _tagITP_FLOW_TIMER
{
PITP_FLOW_CHAN m_PITPFlowChan

PTIMERFUNC m_PITPTimerFunc

}ITP_FLOW_TIMER,*PITP_FLOW_TIMER;

6.
typedef unsigned char (*PFUNC_GETSELFUNITID)();
typedef unsigned long (*PFUNC_GETMODIPPORT)(unsigned char u8ModType,unsigned char u8UnitId,Char * s8IPAddr);
typedef Long (*PFUNC_GETMODINIFILE)(Char * s8IniFile);
typedef unsigned char (*PFUNC_GETMODUNITID)(unsigned int);
typedef unsigned char (*PFUNC_GETMODALLUNITID)(unsigned char u8ModType,unsigned char u8UnitID[]);


typedef struct
{
PFUNC_GETSELFUNITID m_pGetSelfUnitId;
PFUNC_GETMODSTATE m_pGetModState;

}ITP_MOD_CALLBACK,*PITP_MOD_CALLBACK;
//以上这段定义起描述作用,可以不用转换

extern ITP_MOD_CALLBACK g_ITPCallBack;

#define GetSelfUnitId g_ITPCallBack.m_pGetSelfUnitId
#define GetModState g_ITPCallBack.m_pGetModState

----------------------------------------
晕,发出后才发现是两百分,解答后另开帖结分!!
 
都是定义的函数和函数类型
举个例子:
typedef unsigned char (*PFUNC_GETMODALLUNITID)(unsigned char u8ModType,unsigned char u8UnitID[]);
//typedef 相当与type
//unsigned char = byte
//(*PFUNC_GETMODALLUNITID) 相当与函数类型的名字
//后面的就是参数了
delphi中等价与
type PFUNC_GETMODALLUNITID= function(shortint u8ModType,array of byte):byte;

其他的都类似
 
1.
Type
EsrFunc = Procedure(esrParam : Cardinal);cdecl;

ServerID_t = record
m_s8ServerIp : array[0..31] of char;
m_u32ServerPort : Cardinal;
m_s8UserName : array[0..31] of char;
m_s8UserPwd : array[0..31] of char;
end;

PServerID_t = ^ServerID_t;

PrivateData_t = record
m_u32DataSize : Cardinal;
end;

PPrivateData_t = ^PrivateData_t;

Function XMS_acsOpenStream(acsHandle : PCardinal;
serverID : PServerID_t;
u8AppID : DJ_U8;//DJ_U8楼主没给出是什么
privateData : PPrivateData_t
):Integer
stdcall
external 'XXX.DLL';

Function XMS_acsSetESR(acsHandle : Cardinal;
esr : EsrFunc;
esrParam : Cardinal;
notifyAll : LongBool):Integer
stdcall
external 'XXX.DLL';
2.
//Delphi中只有Include文件和宏概念类似.但比较不常用.这里用函数替代

Type
PAcs_Evt_t = ^Acs_Evt_t;
PAcs_Dev_List_Head_t = ^Acs_Dev_List_Head_t;

Function FetchEventData(pAcsEvt : PAcs_Evt_t) : Pointer;
begin
Result := PChar(pAcsEvt) + sizeof(Acs_Evt_t);
end;

Function FetchDeviceList(pAcsEvt: PAcs_Dev_List_Head_t):Pointer;
begin
Result := PChar(FetchEventData(pAcsEvt)) + sizeof(Acs_Dev_List_Head_t);
end;
3.
Type
PKG_HEAD_STRUCT = record
m_u8PkgExtend : Byte;
m_u16DataLen : Cardinal;
ITP_GUID : record
m_u8ModuleType : Byte;
m_u8MainFuncId : Byte;
end;
m_u16Reserve : Cardinal;
end;
PPKG_HEAD_STRUCT = ^PKG_HEAD_STRUCT;
PPPKG_HEAD_STRUCT = ^PPKG_HEAD_STRUCT;

Function ITP_Msg_AttachData(ppPkgHead : PPPKG_HEAD_STRUCT;
u8pData : PByte;
s32DataLen : Integer;):Integer;cdecl
external 'XXX.DLL';


4.
Type
PTIMERFUNC = Function (Param : PInteger):Integer
cdecl;

PITP_FLOW_CHAN = ^ITP_FLOW_CHAN;
PITP_FLOW_INFO = ^ITP_FLOW_INFO;
PITP_RES_CHAN = ^ITP_RES_CHAN;
PITP_FLOW_TIMER = ^ITP_FLOW_TIMER;

ITP_FLOW_INFO = record
m_s8FlowName : array[0..ITP_FLOW_MAX_FLOWNAME_LEN-1] of Byte;
m_hdlDllFunc : array[0..ITP_MAX_DLLFUNC_NUM-1] of PCardinal;
m_PITPFlowChan : PITP_FLOW_CHAN;
end;

ITP_FLOW_CHAN = record
m_PITPFlowInfo : PITP_FLOW_INFO;
m_PITPResList : array[0..ITP_MAX_BINDRES_NUM-1] of PITP_RES_CHAN;
m_PITPTimerChan : array[0..ITP_MAX_BINDTIMER_NUM-1] of PITP_FLOW_TIMER;
m_PITPFlowExtData : PByte;
m_PITPPublicBuf : PByte;
end;

ITP_RES_CHAN = record
m_u8UnitIndex : Byte;
m_s8InfoBuf : array[0..ITP_FLOW_SHOW_INFO_NUM-1, 0..ITP_FLOW_SHOW_INFO_SIZE-1] of char;
end;

ITP_FLOW_TIMER = record
m_PITPFlowChan : PITP_FLOW_CHAN;
m_PITPTimerFunc : PTIMERFUNC;
end;

6.
Type
PFUNC_GETSELFUNITID = Function() : Byte;cdecl;
PFUNC_GETMODIPPORT = Function(u8ModType : Byte
u8UnitId : Byte
s8IPAddr : PChar) : Cardinal
cdecl;
PFUNC_GETMODINIFILE = Function(s8IniFile : PChar):Integer
cdecl;
PFUNC_GETMODUNITID = Function(Param : Cardinal):Byte;cdecl;
PFUNC_GETMODALLUNITID = Function(u8ModType : Byte
u8UnitID : PChar):Byte;cdecl;

PITP_MOD_CALLBACK = ^ITP_MOD_CALLBACK;
ITP_MOD_CALLBACK = record
m_pGetSelfUnitId : PFUNC_GETSELFUNITID;
m_pGetModState : PFUNC_GETMODSTATE;
end;

//extern ITP_MOD_CALLBACK g_ITPCallBack;是C++的全局变量.Delphi中你看着翻译吧

Function GetSelfUnitId():PFUNC_GETSELFUNITID;
begin
Result := g_ITPCallBack.m_pGetSelfUnitId;
end;

Function GetModState():PFUNC_GETMODSTATE;
begin
Result := g_ITPCallBack.m_pGetModState;
end;
 
谢谢武稀松大侠出手,马上测试,明天结帖,另会开一帖补足分数。
 
另有一疑问:
typedef struct _tagITP_FLOW_INFO
{
unsigned char m_s8FlowName[ITP_FLOW_MAX_FLOWNAME_LEN]

unsigned Long* m_hdlDllFunc[ITP_MAX_DLLFUNC_NUM]

PITP_FLOW_CHAN *m_PITPFlowChan

}ITP_FLOW_INFO,*PITP_FLOW_INFO;

typedef unsigned char (*PFUNC_GETSELFUNITID)();
typedef unsigned long (*PFUNC_GETMODIPPORT)(unsigned char u8ModType,unsigned char u8UnitId,Char * s8IPAddr);
typedef Long (*PFUNC_GETMODINIFILE)(Char * s8IniFile);
typedef unsigned char (*PFUNC_GETMODUNITID)(unsigned int);
typedef unsigned char (*PFUNC_GETMODALLUNITID)(unsigned char u8ModType,unsigned char u8UnitID[]);
这两段中
PITP_FLOW_CHAN *m_PITPFlowChan

及(*PFUNC_GETMODINIFILE)....在转换中不用考虑*了?
 
PITP_FLOW_CHAN我在前面已经声明成指针了啊.
 
谢谢武稀松大侠,另请到http://www.delphibbs.com/delphibbs/dispq.asp?lid=3856418
领取不足的分数
 
武稀松大侠,再请到http://www.delphibbs.com/delphibbs/dispq.asp?lid=3861944看看好吗?
 
后退
顶部