在程序中如何取到Windows安装在哪个目录?

解决方案 »

  1.   

    var s1,s2,s3:array[1..40] of char;z1,z2:string;
    begin
    getwindowsdirectory(@s1,40);
    getsystemdirectory(@s2,40);
    z1:=trim(s1);
    z2:=trim(s2);
    showmessage(z1);
    showmessage(z2);
      

  2.   

    var
      s:Pchar;
    begin
      GetMem(s,255);
      GetWindowsDirectory (s);
      FreeMem(s,255);
    end;
      

  3.   

    The GetWindowsDirectory function retrieves the path of the Windows directory. The Windows directory contains such files as applications, initialization files, and help files. UINT GetWindowsDirectory(
      LPTSTR lpBuffer,  // buffer for Windows directory
      UINT uSize        // size of directory buffer
    );
      

  4.   

    GetWindowsDirectory就是获得windows的安装目录的函数。
      

  5.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      WinDir: array[0..MAX_PATH] of char;   // holds the Windows directory
    begin
      {retrieve the Windows directory...}
      GetWindowsDirectory(WinDir, MAX_PATH);  {...and display it}
      Label1.Caption := StrPas(WinDir)
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
      SysDir: array[0..MAX_PATH] of Char;    // holds the system directory
    begin
      {retrieve the system directory and display it}
      GetSystemDirectory(SysDir, MAX_PATH);
      Label1.Caption := StrPas(SysDir)
    end;