为什么一执行CreateFileMapping就出错

yangw79 2005-02-02 03:39:24
PShareData = ^TSharedData;
TSharedData = record
Count :Word;
FileNames:array[1..MaxFileCount] of ShortString;
end;
SharedFile : THandle;
const
SharedFileName = 'Tempest Software.Threaditor shared file';

try
SharedFile := CreateFileMapping($FFFFFFFF,nil,Page_ReadWrite,
0,Sizeof(TSharedData),SharedFileName);
finally
MessageDlg('Error',mtError,[mbOK],0);//这个始终出现
end;
...全文
129 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangw79 2005-02-02
  • 打赏
  • 举报
回复
SharedData.Count := 0; 不好意思 错误不是那 是一执行到这就出错
type
PShareData = ^TSharedData;
TSharedData = record
Count :Word;
FileNames:array[1..4] of ShortString;
end;
const
MaxFileSize = 32768;
MaxFileCount = MaxFileSize div Sizeof(Shortstring);
SharedFileName = 'Tempest Software.Threaditor shared file';

我检查了 SharedData.Count 不能访问 我不晓得是什么意思
劣势 2005-02-02
  • 打赏
  • 举报
回复
是的呀,
try
finally
//这里的任何语句都会执行
end;
这一模板语句的意思无论如何你都要执行finally中的语句,它的异常保护主要是为了一些如对象释放、或一定要执行的语句才设的,所以要搞清楚你的异常保护需要怎样做,except是在出现异常的时候及时保护,这样的好处是可以屏蔽一些错误信息
beyondtkl 2005-02-02
  • 打赏
  • 举报
回复
try

except
ShowMessage(IntToStr(GetLastError));
end;

not finally

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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