在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
//1、打开目录和打开txt文件 procedure TMainForm.bbtnOpenLoClick(Sender: TObject); var sLogName: string; begin sLogName := Pub_EXEPath + '\日志\' + FormatDateTime('yyyy-mm-dd',date())+'.txt'; if not FileExists(sLogName) then begin MessageBox(0, '今日无错误日志!', '提示', MB_OK + MB_ICONINFORMATION); Exit; end; try OpenLog(sLogName); except on E : Exception do begin LogInfo('打开日志文件出错,原因:' + E.Message, True); MessageBox(0, '打开日志文件出错,请重试!', '错误', MB_OK + MB_ICONERROR); end; end; end; procedure TMainForm.bbtnOpenLogFolderClick(Sender: TObject); var sDirName: string; begin sDirName := Pub_EXEPath + '\日志'; if not DirectoryExists(sDirName) then CreateDir(sDirName); try OpenLogDirectory(sDirName); except on E : Exception do begin LogInfo('打开日志目录出错,原因:' + E.Message, True); MessageBox(0, '打开日志目录出错,请重试!', '错误', MB_OK + MB_ICONERROR); end; end; end; ------- procedure TMainForm.OpenLogDirectory(DirName: string); begin ShellExecute(Handle,'Open',PChar(DirName), nil, nil, 1); end; procedure TMainForm.OpenLog(FileName: string); begin ShellExecute(Handle, 'Open', PChar('NotePad'), PChar(FileName), nil, SW_SHOW); end;
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论