Win32函数获取C:\ ProgramData的路径

时间:2012-06-25 19:36:22

标签: winapi path programdata

我的应用需要安装一些可以在运行时由应用程序编辑的文件。安装shield提供了一个别名[CommonAppDataFolder],它将在Vista和Windows 7上解析为c:\ programData,也可以在Windows XP上运行。是否有返回类似路径的win32函数?

也许我需要根据操作系统调用不同的函数?

2 个答案:

答案 0 :(得分:21)

SHGetFolderPath / SHGetSpecialFolderPath通过CSIDL_COMMON_APPDATA参数获得该信息。

请参阅此处的代码段(位于底部):How to write a Windows XP Application that stores user and application data in the correct location by using Visual C++

  • Windows XP:C:\ Documents and Settings \ All Users \ Application Data
  • Windows Vista:C:\ ProgramData
  • Windows 7:C:\ ProgramData

另请参阅:CSIDL

答案 1 :(得分:0)

自从Delphi XE5 起,此功能就是框架的一部分。

  • 单位:System.IOUtils
  • 类别:TPath
  • 功能: GetPublicPath

有关更多信息,请参见embarcadero docwiki