【delphi开源代码栏目提醒】:网学会员为广大网友收集整理了,frmFileInUse.pas,希望对大家有所帮助!
unit frmFileInUse;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, XPMan;
type
TFrmFileIsInUse = class(TForm)
BtnInUse: TButton;
RGStatus: TRadioGroup;
BtnClose: TButton;
ODFile: TOpenDialog;
procedure BtnInUseClick(Sender: TObject);
procedure BtnCloseClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmFileIsInUse: TFrmFileIsInUse;
implementation
{$R *.dfm}
function FileINUse(filename:String):boolean;
var
usein:file;
begin
result:=false;
assignfile(usein,FileName);
try
reset(Usein);
except
on E:EInOutError do
begin
if e.ErrorCode=32 then
begin
result:=true;
exit;
end;
end;
end;
closefile(usein);
end;
procedure TFrmFileIsInUse.BtnInUseClick(Sender: TObject);
begin
if ODFile.Execute then
begin
if fileInuse(ODFile.filename) then
RGStatus.ItemIndex:=0
else
RGStatus.ItemIndex:=1;
end;
end;
procedure TFrmFileIsInUse.BtnCloseClick(Sender: TObject);
begin
Close;
end;
end.