VC下的变量类型和delphi下的是怎么对应的呀?
wenls 2003-12-17 10:05:59 VC下的变量和delphi下的是怎么对应的呀?
由于有一些硬件卡上提供的API是C写的,现在有一个这些函数原型的C语音的头文件
现在我们在Delphi下需要使用这些函数,需在delphi下重新定义,不知这些类型是怎么对照的
32为的平台
C delphi
long ?
int Integer
char char
bool boolean
char * ?
? String
? Pchar
word ?
DWord ?
还有, API中有一个需要用到函数指针,即使用回调函数
C下是这么用的
int WINAPI DJH323_SetCallEventHandler( DWORD dwEventMask, long (WINAPI * hdlr)(DWORD dwEvent, int iChID));
long WINAPI IPCallBackProc(DWORD dwEvent, int ch)
{
......
}
调用时: DJH323_SetCallEventHandler(H323_EV_ALL, IPCallBackProc);
我在delphi下这么定义:
type TIPCallBackProc= function(dwEvent: DWORD; iChID: Integer ):Integer;stdcall ;
function DJH323_SetCallEventHandler( dwEventMask: DWORD; IPCallBackProc: TIPCallBackProc):Integer; stdcall; far external 'djH323.dll';
函数实体
function IPCallBackProc( dwEvent: DWORD; IPch:Integer ):Integer;stdcall ;
begin
end;
调用时: DJH323_SetCallEventHandler(H323_EV_ALL, @IPCallBackProc);
可不知道为什么总是出错,好象是堆栈不一致,提示信息:
Debug Error!
Program : D:\....\project1.exe
Module:
file: i386\chkesp.c
line: 42
The value of esp was not properly save across a function call. this is usually of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
这里C语音下的 long (WINAPI * hdlr) 在delphi下怎么处理呀?
小弟在此先谢过了
//bow