如何获取当前系统system32文件夹的路径?

解决方案 »

  1.   

    uses ShlObj, ActiveX;function GetSystemPath(Folder: Integer): string;
    var
       PIDL: PItemIDList;
       Path: LPSTR;
       AMalloc: IMalloc;
    begin
       Path := StrAlloc(MAX_PATH);
       SHGetSpecialFolderLocation(Application.Handle, Folder, PIDL);
       if SHGetPathFromIDList(PIDL, Path) then
           Result := Path;
       SHGetMalloc(AMalloc);
       AMalloc.Free(PIDL);
       StrDispose(Path);
    end;
      

  2.   

    直接用API
    var
      key,Sys32Dir: string;
      pSys32Dir: array[0..Max_Path] of char;
    begin
      GetSystemDirectory(pSys32Dir,Max_Path);
      Sys32Dir := StrPas(pSys32Dir);
      ShowMessage(Sys32Dir);
    end;