请问系统盘的路径怎么表示,比如我要打开系统盘windows下的exe,而用户使用的操作系统有可能在C盘,D盘,E盘……等等。那么如何表示系统盘路径呢?如果我要调用一个程序,比如是msconfig,或者是其他非微软的exe那么又应该怎样写呢?

解决方案 »

  1.   

    procedure TForm1.Button2Click(Sender: TObject);
    var
      Buf: array [0..255] of Char;
    begin
      Windows.GetWindowsDirectory(Buf, SizeOf(Buf));
      ShowMessage(StrPas(Buf));
    end;
      

  2.   

    1 获取系统所在的盘符:
    function GetSystemDisk():Char;
    var Path:PChar;
    begin
      GetMem(Path,255);
      GetSystemDirectory(Path, 255);
      Result:=Path[0];
      FreeMem(Path);
    end;2 调用msconfig.exe ,记住要加uese ShellAPI
    ShellExecute(Handle,'open','msconfig.exe','','',SW_SHOW);
      

  3.   

    ExtractFilePath(Application.exeName);
    获得exe文件所在的路径