简单的程序:
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
AssignFile(DealFile,Opendialog1.FileName);
Reset(DealFile);
end;
end;我的问题是:如果我打开选择文件对话框后,并不选择任何文件。是否有办法通过判断DealFile这个变量来确定是否assign了文件?谢谢!
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
AssignFile(DealFile,Opendialog1.FileName);
Reset(DealFile);
end;
end;我的问题是:如果我打开选择文件对话框后,并不选择任何文件。是否有办法通过判断DealFile这个变量来确定是否assign了文件?谢谢!
解决方案 »
- listbox出现list index out of bounds错误,求解?在线等、、、
- 各位高手,请教一个问题。十万火急,在线等
- 怎么强制设定DBGrid的列宽
- 不想给别人打工了,想去做学生意, 自己干, 不知道现在做什么生意比较好!!!
- clientDateset中保留相应数据的问题
- 实现承诺:aiirii(aiirii)进来领分!!
- 提示:DB-Libarary未装载网络通信层,是何原因?
- !!!打印问题
- 如何在Delphi的ServerSocket控件中使用自己定义的阻塞线程?
- 如何在浏览器中显示/调用ActiveXForm
- 关于串口通讯的问题
- 请教怎么在显示数据的DBGridEh2上加一个复选框?
begin
if OpenDialog1.Execute then
begin
AssignFile(DealFile,Opendialog1.FileName);
Reset(DealFile);
end;
else
showmessage('请选择文件');
end;
closefile(DealFile);AssignFile(DealFile,FName);
Reset(DealFile);
var
R: TTextRec absolute DealFile;
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
AssignFile(DealFile,Opendialog1.FileName);
Reset(DealFile);
if R.Handle > 0 then
ShowMessage('文件已经打开');
end;
end;
Delphi 5.0
sozeof(File) 得到 332
sozeof(TextFile) 得到 460另外用个标志变量,与DealFile同步修改吧。
R: TFileRec absolute DealFile;
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
AssignFile(DealFile,Opendialog1.FileName);
Reset(DealFile);
if R.Handle > 0 then
ShowMessage('文件已经打开');
end;
end;
2个结构 TFileRec = packed record (* must match the size the compiler generates: 332 bytes *)
Handle: Integer;
Mode: Word;
Flags: Word;
case Byte of
0: (RecSize: Cardinal); // files of record
1: (BufSize: Cardinal; // text files
BufPos: Cardinal;
BufEnd: Cardinal;
BufPtr: PChar;
OpenFunc: Pointer;
InOutFunc: Pointer;
FlushFunc: Pointer;
CloseFunc: Pointer;
UserData: array[1..32] of Byte;
Name: array[0..259] of Char; );
end;{ Text file record structure used for Text files }
PTextBuf = ^TTextBuf;
TTextBuf = array[0..127] of Char;
TTextRec = packed record (* must match the size the compiler generates: 460 bytes *)
Handle: Integer; (* must overlay with TFileRec *)
Mode: Word;
Flags: Word;
BufSize: Cardinal;
BufPos: Cardinal;
BufEnd: Cardinal;
BufPtr: PChar;
OpenFunc: Pointer;
InOutFunc: Pointer;
FlushFunc: Pointer;
CloseFunc: Pointer;
UserData: array[1..32] of Byte;
Name: array[0..259] of Char;
Buffer: TTextBuf;
end;