Delphi DirectoryExists()无法正确检测文件夹

时间:2016-10-21 20:41:43

标签: delphi delphi-2010

我目前正在运行Delphi 2010,每当我尝试运行它时,它总是返回该文件夹存在,即使它没有。我试图用预配置的Registry.pol替换Registry.pol进行测试。

    procedure TForm2.Button1Click(Sender: TObject);
    var
      ResStream: TResourceStream;
    begin
      if DirectoryExists('C:\WINDOWS\System32\GroupPolicy\Machine') then
        begin
          ResStream := TResourceStream.Create(HInstance, 'AutoRestartWindowsDefault', RT_RCDATA);
          ResStream.SaveToFile('C:\WINDOWS\System32\GroupPolicy\Machine\Registry.pol');
          ResStream.Free;
        end
      else
      begin
        ShellExecute(Handle, 'runas', 'cmd.exe', '/K md C:\WINDOWS\System32\GroupPolicy\Machine', nil, SW_SHOWNORMAL);
      end;
    end;

0 个答案:

没有答案