delphi假脱机文件列表

时间:2018-11-16 02:52:58

标签: delphi

开发环境是Windows 10 64位Delphi xe2。 我要复制一个假脱机文件。 我实际上在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;

1 个答案:

答案 0 :(得分:0)

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

因此,您需要以提升的权限(例如“以管理员身份运行”)运行程序。

相关问题