代码之家  ›  专栏  ›  技术社区  ›  Vibeeshan Mahadeva

在delphi中获取我的文档文件夹路径

  •  10
  • Vibeeshan Mahadeva  · 技术社区  · 14 年前

    我使用以下代码获取特殊目录

    uses
      ActiveX, ShlObj;
    
    {...}
    
    procedure TForm1.Button1Click(Sender: TObject);
    // Replace CSIDL_HISTORY with the constants below
    var
      Allocator: IMalloc;
      SpecialDir: PItemIdList;
      FBuf: array[0..MAX_PATH] of Char;
      PerDir: string;
    begin
      if SHGetMalloc(Allocator) = NOERROR then
      begin
        SHGetSpecialFolderLocation(Form1.Handle, CSIDL_PERSONAL, SpecialDir);
        SHGetPathFromIDList(SpecialDir, @FBuf[0]);
        Allocator.Free(SpecialDir);
        ShowMessage(string(FBuf));
      end;
    end;
    

    所以我用 但我怀疑这是所有windows电脑(personalfolder/documents)上的mydocuments路径,用户是否可以更改此结构并使mydocuments文件夹成为其他文件夹(例如:c:\ documents) 如果用户更改了路径,给了我一个正确的方法,我想知道My Documents文件夹的名称(mydocuments或Documents)

    2 回复  |  直到 11 年前
        1
  •  15
  •   Marjan Venema    14 年前

    CSIDL U个人

    个人文件夹文件 版本6.0。虚拟文件夹 表示“我的文档”桌面 物品。这相当于 我的文件。

    用于物理上 文件。典型的路径是 C: \Documents and Settings\username\My文档和设置 文件。这应该是 命名空间中的文档文件夹。到 访问该虚拟文件夹,使用 SHGetFolderLocation,它返回 或参考 管理文件系统。管理文件系统。

    http://msdn.microsoft.com/en-us/library/bb762494(VS.85).aspx 所有可用CSIDL常量的列表和说明

        2
  •  19
  •   Marjan Venema    10 年前

    System.IOUtils 在你的 uses 然后使用 TPath.GetDocumentsPath 获取文档文件夹。

    Doc Wiki