各位大侠:
小弟想在c:\winnt放置一个文件a.txt,如何在程序运行时检测并判断是否存在此文件,如果存在则运行程序,否则产生一警告信息并退出程序,请给出代码,谢谢!
小弟想在c:\winnt放置一个文件a.txt,如何在程序运行时检测并判断是否存在此文件,如果存在则运行程序,否则产生一警告信息并退出程序,请给出代码,谢谢!
解决方案 »
- 错在哪里?如何能读取TreeView1节点标识号?
- 如何解决Excel文件中的复制图像,粘贴到Delphi的Image控件中
- 串口MSComm分析读取的数据问题,没人能解决么
- 执行form2.show;或者form2.showmodal;时死机
- delphi程序员转型
- 怎样判断变量的类型 ?stringgrid1.cells[i,j]启出来的值是什么类型的?
- data module在动态链接库(dll)开发中如何使用?最好能提供一段代码,谢谢!
- 高手请教:label控件颜色的依次显现
- 打开模块时 Class TDSEditing not found. 帮忙看下是缺少那个控件...
- 为何我的dll通不过?
- 怎樣在sql中把所要先的字段用變量傳入
- 一个关于修改数据库字段的问题!!!!
if FileExists(WinDir) then ShellExecute(handle, 'open', windir, nil, nil, SW_SHOWNORMAL)
else
begin
showmessage('无此程序’);
Application.Terminate;
end;
Forms,windows,dialogs,SysUtils,
Unit1 in 'Unit1.pas' {Form1};{$R *.res}
var
WinDir: array[0..MAX_PATH] of char; // holds the Windows directory
begin
Application.Initialize;
{retrieve the Windows directory...}
GetWindowsDirectory(WinDir, MAX_PATH);
if not fileexists(StrPas(WinDir)+'\'+'a.txt') then
begin
showmessage('存在文件推出程序');
application.Terminate;
end;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.