DELPHI7 函数原型
function SetDoorGuardPeriods(hPort: THandle; Fun: Byte; ts: array of TDoorTimePeriods;Count:Integer; week: Byte=0): Boolean;stdcall;
VC6 定义原型
typedef BOOL (PASCAL *ECSetDoorGuardPeriods)(HANDLE hPort, byte Fun,TDoorTimePeriods *ts,const int Count, const byte week=0);
BOOL bSuc = SetDoorGuardPeriods(m_hComHandle,Fun,ts,Count,week);
结果:样本 Vc6调用 :SetDoorGuardPeriods(1900,1,ts[1],1,0)
DLL传入 :1900,1,ts[2],13012481,96 问题 1 count \week两个数据不对
2 ts的长度与count相关 len(ts) = count+1
还请各位高手指点一二!谢谢
function SetDoorGuardPeriods(hPort: THandle; Fun: Byte; ts: array of TDoorTimePeriods;Count:Integer; week: Byte=0): Boolean;stdcall;
VC6 定义原型
typedef BOOL (PASCAL *ECSetDoorGuardPeriods)(HANDLE hPort, byte Fun,TDoorTimePeriods *ts,const int Count, const byte week=0);
BOOL bSuc = SetDoorGuardPeriods(m_hComHandle,Fun,ts,Count,week);
结果:样本 Vc6调用 :SetDoorGuardPeriods(1900,1,ts[1],1,0)
DLL传入 :1900,1,ts[2],13012481,96 问题 1 count \week两个数据不对
2 ts的长度与count相关 len(ts) = count+1
还请各位高手指点一二!谢谢
struct TDoorTimePeriod
{
int TimeHour; // 小时[0..23]
int TimeMinute; // 分钟[0..59]
};struct TDoorTimePeriods
{
TDoorTimePeriod StartTime; // 时段的开始时间
TDoorTimePeriod EndTime; // 时段的结束时间
int Right;
};
取的数据是正确的。
谢谢楼上两位兄弟的关心
{
ECSetDoorGuardPeriods SetDoorGuardPeriods;
if (!m_hModuleEastRiver)
{
return 1;
}
else
{
SetDoorGuardPeriods = (ECSetDoorGuardPeriods)GetProcAddress(m_hModuleEastRiver,"SetDoorGuardPeriods");
if (SetDoorGuardPeriods != NULL)
{
BOOL bSuc = SetDoorGuardPeriods(m_hComHandle,Fun,ts,Count,week);
if (bSuc != FALSE)
{
return 0;
}
}
}
return 1;
}
这个是具体的DLL调用,被申明在一个class中
关于这点是不是有可能count值把ts内存中表示长度的值给覆盖了?
做了好多次测试了,即使我VC定义TS的长度为1,调用count =30时候,内存依然没有报错。
但是取出来的数据除开定义的数据外,多余的都是系统随机的数据。
为什么会这样呢?DLL传递参数到底是怎么进行的呢?