How to write to the application data shared folder?

I have a Visual Basic 6.0 application that I want to install for all users, for example, the settings are stored in one place regardless of who logs on to the computer. I have the following code to find a general location:

Const ssfCOMMONAPPDATA = &H23 Dim strAllUsersPath As String strAllUsersPath = CreateObject("Shell.Application").NameSpace(ssfCOMMONAPPDATA).Self.Path 

In Windows XP, this path points to the folder C:\Documents and Settings\All Users\Application Data\ . Setup copies the settings file there, and everything is fine. Visual Basic 6.0 can change it at any time.

On Windows 7, this path points to the c:\ProgramData . A setting that requires administrator rights copies the file there. However, when the Visual Basic 6.0 application starts and accesses the file, Windows 7 copies the settings file to C: \ Users {USER LOGIN} \ AppData \ Local \ VirtualStore \ and performs all operations on it. As a result, since for each user Windows 7 copies the settings file to a separate user directory, users have a different settings file.

Am I storing the file in the wrong place? Am I doing it wrong?

+4
source share
1 answer

This one also bit me. The ProgramData folder has read-only access, without shared write access. You can, of course, change the permissions on the folder during installation, but I think this contradicts the way Microsoft understood it. See this other question for some useful links.

As Microsoft believes this should be done.

+9
source

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


All Articles