小编Luk*_*jan的帖子

Delphi多个.ini文件操作

最近,我遇到了一个小问题,在尝试读取.ini文件时会导致访问冲突.

我的问题是,我可以在同一个程序中加载多个.ini文件(例如settings.ini和data.ini)吗?例如,我有两个ini文件,我写入并读取.

这是一个缩短的proc,它写入数据:

//writing to file uninstall.ini
try
  ini := TIniFile.Create(edPath.Text + '\Uninstall.ini');
  ini.WriteString('Uninstall', 'qfProgramName', Label4.Caption);
  ini.WriteString('Uninstall', 'qfUninstPath', edPath.Text);
finally
  ini.Free;
end;
Run Code Online (Sandbox Code Playgroud)

然后,有这个代码(在相同的程序中)

configini := configini.Create(ExtractFilePath(Application.ExeName) + '\quickfix.ini');
sectionsCount := getMaxSectionIndex(ExtractFilePath(Application.ExeName) + '\quickfix.ini');

startmenuLoc := GetProperDir(_STARTMENU);
desktopLoc := GetProperDir(_DESKTOP);
for I := 1 to sectionsCount do begin
  currentSection := 'qfShortcut_' + IntToStr(I);
  shortcutFile := configini.ReadString(currentSection, 'qfShTarget', '');
  shortcutDesc := configini.ReadString(currentSection, 'qfShDescription', '');
  shortcutFullPath := installPath + '\' + shortcutFile;
  shortcutDest := configini.ReadString(currentSection, 'qfShPath', '');
  displayName := configini.ReadString(currentSection, 'qfDisplayName', '');

  showmessage(startmenuLoc …
Run Code Online (Sandbox Code Playgroud)

delphi ini

0
推荐指数
1
解决办法
561
查看次数

Delphi - 从Program Files文件夹Win7生成文件

最近我遇到了文件创建问题,当我的delphi应用程序使用开始菜单或桌面快捷方式执行时,即使它以管理员身份运行.如果我直接从其文件夹中以管理员身份运行它,则没有问题.

基本上我已经创建了一个delphi 32位GUI程序,它使用zipforge归档程序构建SFX归档.如果我从例如C:\ myProgramFolder运行程序,应用程序正常运行并将存档构建到指定的输出文件夹,但是,当我使用快捷方式运行它时,我得到的是I/O 105.我想这应该是有问题的东西与Win7安全策略有关,但也许有人曾经处理过这类问题,所以我非常感谢任何建议.

这是一个导致I/O 105的过程:

quickfix.ini是一个文件,用于为SFX存根提供显示信息,这就是它存在的原因

procedure TfrmMain.Buildinstaller1Click(Sender: TObject);
var
  presentPath: string;
begin
  presentPath := ExtractFilePath(Application.ExeName);
  SynEdit1.Lines.SaveToFile(presentPath + '\quickfix.ini');
  CopyFile(pchar(presentPath + '\quickfix.ini'),
      pchar(edSourcePath.Text + '\quickfix.ini'), false);
  CopyFile(pchar(presentPath + '\bin\Uninstall.exe'),
      pchar(edSourcePath.Text + '\Uninstall.exe'), false);
  DeleteFile(presentPath + '\quickfix.ini');
  if (edSourcePath.Text <> '') and (edOutPutPath.Text <> '') then begin
    saveExe.InitialDir := edOutPutPath.Text;
    if saveExe.Execute() then begin
      frmProgress.Show;
      try
        // this is a line where the problem begins
        with archiver do begin
          TempDir := GetTempDirectory;
          FileName := saveExe.FileName;
          OpenArchive(fmCreate);
          BaseDir := edSourcePath.Text; …
Run Code Online (Sandbox Code Playgroud)

delphi windows-7

-3
推荐指数
1
解决办法
658
查看次数

标签 统计

delphi ×2

ini ×1

windows-7 ×1