如何写入公共应用程序数据文件夹? [英] How to write to the common Application Data folder?

查看:38
本文介绍了如何写入公共应用程序数据文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Visual Basic 6.0 应用程序,我想为 所有用户 安装它,例如,无论谁登录计算机,该设置都保存在一个位置.我有以下代码来定位公共位置:

I have a Visual Basic 6.0 application that I want to install for All Users, for example, the setting are held in a single spot regardless who logs into the computer. I have the following code to locate the common location:

Const ssfCOMMONAPPDATA = &H23
Dim strAllUsersPath As String

strAllUsersPath = CreateObject("Shell.Application").NameSpace(ssfCOMMONAPPDATA).Self.Path

在 Windows XP 上,此路径指向 C:Documents and SettingsAll UsersApplication Data 文件夹.设置将设置文件复制到那里,一切都很好.Visual Basic 6.0 应用程序可以随时更改它.

On Windows XP, this path points to C:Documents and SettingsAll UsersApplication Data folder. The setup copies the settings file there and everything is great. The Visual Basic 6.0 app can change it at any time.

在 Windows 7 上,此路径指向 c:ProgramData 文件夹.需要管理员权限的设置将文件复制到那里.但是,当我的 Visual Basic 6.0 应用程序启动并访问该文件时,Windows 7 会将设置文件复制到 C:Users{USER LOGIN}AppDataLocalVirtualStore 并在那里执行所有操作.结果,因为对于每个用户,Windows 7 将设置文件复制到单独的用户目录,用户最终拥有不同的设置文件.

On Windows 7, this path points to c:ProgramData folder. The setup, which requires administrator privileges, copies the file there. However, when my Visual Basic 6.0 application starts and accesses the file, Windows 7 copies the settings file to a C:Users{USER LOGIN}AppDataLocalVirtualStore and performs all the operations on it there. As a result, because for each user, Windows 7 copies the settings file to a separate user directory, the users end up having a different settings file.

我是否将文件存储在错误的位置?我这样做的方式不正确吗?

Am I storing the file in the wrong location? Am I doing it in the incorrect manner?

推荐答案

这个也咬到我了.ProgramData 文件夹具有共享读取访问权限,没有共享写入访问权限.您当然可以在安装过程中更改文件夹的权限,但我认为这与微软的意图相反.请参阅 this other question 获取一些有用的链接

This one has bitten me too. The ProgramData folder has shared Read Access, no shared write access. You can of course change the permission on the folder during install, but I think that goes contrary to how Microsoft meant it to be. See this other question for some useful links

微软认为应该怎么做.

这篇关于如何写入公共应用程序数据文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆