【问题标题】:delphi Spool file listdelphi 假脱机文件列表
【发布时间】:2018-11-16 02:52:57
【问题描述】:

开发环境为Delphi xe2,Windows 10 64位。 我要复制一个假脱机文件。 我将驱动程序虚拟安装在 LPT1 端口上。驱动程序处于暂停状态。 您即将从文件夹 C:\Windows\System32\spool\PRINTERS 导入 .spl 文件和 .shd 文件。 但是,无法调用该文件夹中的文件列表。 如何将列表导入该文件夹?

function FindFiles(const sPath, sMask: string; slFiles: TStringList; bSubDir: boolean): integer;
var
  iFindResult: integer;
 srSchRec : TSearchRec;
begin
  result := 0;

  iFindResult := FindFirst(sPath + sMask, faAnyFile - faDirectory, srSchRec);
  while iFindResult = 0 do
  begin
    slFiles.Add(sPath + srSchRec.Name);
    iFindResult := FindNext(srSchRec);
  end;
  FindClose(srSchRec);

  if bSubDir then
  begin
    iFindResult := FindFirst(sPath + '*.*', faDirectory, srSchRec);
    while iFindResult = 0 do
    begin
      if (srSchRec.Name <> '.') and (srSchRec.Name <> '..') then
        result := result + FindFiles(sPath + srSchRec.Name + '\', sMask, slFiles, TRUE);
      iFindResult := FindNext(srSchRec);
    end;
    FindClose(srSchRec);
  end;
end;

【问题讨论】:

    标签: delphi


    【解决方案1】:

    如我所见,访问C:\Windows\System32\spool\PRINTERS 需要管理员权限,此目录受 UAC 保护。

    因此,您需要以“以管理员身份运行”等提升权限运行程序。

    【讨论】:

    • 虽然被批准,但同样的问题仍然存在。
    猜你喜欢
    • 1970-01-01
    • 2011-05-08
    • 1970-01-01
    • 2012-07-30
    • 2016-12-27
    • 2017-02-14
    • 1970-01-01
    • 1970-01-01
    • 2020-07-02
    相关资源
    最近更新 更多