提示:Access violation at address 00cf85f1.read of address 24400042.

海嵌 2005-09-22 10:18:45
调用:
void __fastcall TForm1::Btn_InitClick(TObject *Sender)
{
WimDev_Init(0);//this parameter can chose -1~10.
}

dll:
h.
struct CARTIME
{
int data_year;
int data_month;
int data_day;
int data_hour;
int data_minute;
int data_second;
};
struct S_MESSAGE //信息
{
bool flag;
int data_length;
struct CARTIME car_time;
long car_speed;
int car_Aa;
int car_Count;
int car_ZZS;
int car_Width;
char car_type[20];
};
class TFormMain
{
public:
__fastcall TFormMain();
virtual __fastcall ~TFormMain();
struct S_MESSAGE RecvData[10];
int carNum; // »º³åÇøÖгµÁ¾ÊýÄ¿
int index;
}
cpp.
int TFormMain::WimDev_Init(int IniType)
{
if(IniType==0)
{
for(int i=0;i<10;i++)
RecvData[i].flag=false;
return 0;
}
if(IniType==-1)
{
for(int i=0;i<10;i++)
RecvData[i].flag=false;
return carNum;
}
if(IniType>0 && IniType<10)
{
for(int i=10;i<IniType;i--)
RecvData[(10+index-i+1)%10].flag=false;
return IniType;
}
else return -1;
}

不知道为什么出现如题提示!
win2k+sp4,谢谢
...全文
294 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
海嵌 2005-09-23
  • 打赏
  • 举报
回复
从汇编的角度看,传递 0 的操作应该是立即数寻址;
程序是不是分不清参数,对WimDev_Init(0)是dll自身的参数还是exe传递的参数,而把立即数认为是地址越界而报错!
nuelaleo 2005-09-23
  • 打赏
  • 举报
回复
你的程序访问了一个不存在的对象或变量,这个对象或变量要么还没被创建,要么已经被释放。
请仔细跟踪你的程序,看在哪里出的错。
alloutoflove 2005-09-23
  • 打赏
  • 举报
回复
for(int i=10;i<IniType;i--) //执行(10-IniType)次循环

i<IniType我感觉应该是i > IniType
海嵌 2005-09-22
  • 打赏
  • 举报
回复
for(int i=10;i<IniType;i--) //执行(10-IniType)次循环

调用:
void __fastcall TForm1::Btn_InitClick(TObject *Sender)
{
// WimDev_Init(0);//this parameter can chose -1~10.
WimDev_Init(Edit1->Text.ToInt());//正常
}

请知道实质的给点解释!
海嵌 2005-09-22
  • 打赏
  • 举报
回复
谢谢大家.

调用:
void __fastcall TForm1::Btn_InitClick(TObject *Sender)
{
// WimDev_Init(0);//this parameter can chose -1~10.
WimDev_Init(Edit1->Text.ToInt());//正常
}

请知道实质的给点解释!
alloutoflove 2005-09-22
  • 打赏
  • 举报
回复
看不出哪有问题,不过你前面提到在dll中????

还有:
for(int i=10;i<IniType;i--)
这一句????????????
海嵌 2005-09-22
  • 打赏
  • 举报
回复
int TFormMain::WimDev_Init(int IniType)
{
ShowMessage("OK");
return 1;
}
显示ok以后还弹出如题提示?!
海嵌 2005-09-22
  • 打赏
  • 举报
回复
int TFormMain::Init(int IniType)
{
ShowMessage("OK");
return 1;
}
显示ok以后还弹出如题提示?!
xibingwuqing 2005-09-22
  • 打赏
  • 举报
回复
是不是没有new空间的原因?

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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