Vista and ProgramData

后端 未结 5 1700
名媛妹妹
名媛妹妹 2020-12-06 16:53

What is the right place to store program data files which are the same for every user but have to be writeable for the program? What would be the equivalent location on MS W

相关标签:
5条回答
  • 2020-12-06 17:12

    You can use:

    CString strPath;
    ::SHGetSpecialFolderPath(NULL, strPath.GetBuffer(1024), CSIDL_COMMON_APPDATA, FALSE);
    
    0 讨论(0)
  • 2020-12-06 17:17

    There is a great summary of the different options here: http://blogs.msdn.com/cjacks/archive/2008/02/05/where-should-i-write-program-data-instead-of-program-files.aspx

    Where Should I Write Program Data Instead of Program Files?

    A common application code update is this: "my application used to write files to program files. It felt like as good a place to put it as any other. It had my application's name on it already, and because my users were admins, it worked fine. But now I see that this may not be as great a place to stick things as I once thought, because with UAC even Administrators run with standard user-like privileges most of the time. So, where should I put my files instead?"

    0 讨论(0)
  • 2020-12-06 17:18

    Actually SHGetFolderPath is deprecated.

    SHGetKnownFolderPath should be used instead.

    0 讨论(0)
  • 2020-12-06 17:30

    SHGetFolderPath() with CSIDL of CSIDL_COMMON_APPDATA.

    Read more at http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx

    If you need the path in a batch file, you can also use the %ALLUSERSPROFILE% environment variable.

    0 讨论(0)
  • 2020-12-06 17:30

    See Raymond Chen's article on this specific question.

    In short you're asking for a security hole.

    0 讨论(0)
提交回复
热议问题