怎样得到WINDOWS的SYSTEM路径?

解决方案 »

  1.   

    Win API函数
    UINT GetSystemDirectory(
      LPTSTR lpBuffer,  // buffer for system directory
      UINT uSize        // size of directory buffer
    );
      

  2.   

    第一个参数是一个以null结束的字符串缓冲区,用于返回System目录位置。第二个参数用于指定缓冲区的大小。
      

  3.   

    分点分吧,哈哈,翻译一下Win API函数
    UINT GetSystemDirectory(
      LPTSTR lpBuffer,  // 以null结束的字符串缓冲区,用于返回System目录位置
      UINT uSize        // 指定缓冲区的大小
    );
      

  4.   

    方法:
    var
     MySysPath:PCHAR;
    begin
     GetMem(MySysPath,255);
     GetSystemDirectory(MySysPath,255);
    end;
    注:MySysPath为SYSTEM路径
      

  5.   

    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);
    end;
    以上为WINDOWS及WINDOWS SYSTEM目录的代码
      

  6.   

    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;