Shared folder with world data in the world of Vista / Windows 7 applications

I am trying to find a folder in which members of the Users group in Vista and Windows 7 by default have write permission without elevation.

This should be used to store common data (a database and a regularly updated set of documents) that should be publicly available and writable by all users.

I thought that somewhere I have CSIDL_COMMON_APPDATA, which allows c: \ ProgramData in Vista, however, when testing, we found that members of the Users group only have Read / Execute permissions when the machine is connected to a domain. This is contrary to the documentation:

CSIDL _ COMMON _ APPDATA (FOLDERID_ProgramData) Version 5.0.

A file system directory that contains application data for all users. Typical path: C: \ Documents and Settings \ All users \ Application Data. This folder is used for application data that are not specific users. For example, an application might store a spellcheck dictionary, clip database, or log file in the CSIDL_COMMON_APPDATA folder. This information will not wander and is accessible to anyone who uses a computer.

http://msdn.microsoft.com/en-us/library/bb762494(VS.85).aspx

I do not want to use a folder with documents (for example, CSIDL_COMMON_DOCUMENTS), because these files should not be especially noticeable to the user.

The code that I use to determine the CSIDL values ​​for the path is interesting here.

public enum CSIDL : int
{
  COMMON_APPDATA = 0x0023
  // etc
}

public static class Folders
{
  [DllImport("shell32.dll")]
  static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, [Out]StringBuilder lpszPath, int nFolder, bool fCreate);

  public static string GetCsidlValue(CSIDL csidl)
  {
    StringBuilder path = new StringBuilder(260);
    SHGetSpecialFolderPath(IntPtr.Zero, path, (int)csidl, false);
    return path.ToString();
  }

  public static string GetCommonAppDataFolder()
  {
    return GetCsidlValue(CSIDL.COMMON_APPDATA);
  }
}

Any suggestions?

: , System.Environment.SpecialFolder. (COMMON_DOCUMENTS - 0x002e), :

public enum SpecialFolder
{
  ApplicationData = 0x1a,
  CommonApplicationData = 0x23,
  CommonProgramFiles = 0x2b,
  Cookies = 0x21,
  Desktop = 0,
  DesktopDirectory = 0x10,
  Favorites = 6,
  History = 0x22,
  InternetCache = 0x20,
  LocalApplicationData = 0x1c,
  MyComputer = 0x11,
  MyDocuments = 5,
  MyMusic = 13,
  MyPictures = 0x27,
  Personal = 5,
  ProgramFiles = 0x26,
  Programs = 2,
  Recent = 8,
  SendTo = 9,
  StartMenu = 11,
  Startup = 7,
  System = 0x25,
  Templates = 0x15
}

: , .

http://blogs.msdn.com/oldnewthing/archive/2004/11/22/267890.aspx

, -, , . ACL , CLI. , .

+3

Source: https://habr.com/ru/post/1722433/


All Articles