如何写到通用的Application Data文件夹? [英] How to write to the common Application Data folder?

查看:175
本文介绍了如何写到通用的Application Data文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要为所有用户安装的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 Settings\All Users\Application Data\ 文件夹。安装程序将设置文件复制到那里,一切都很好。 Visual Basic 6.0应用程序可以随时更改它。

On Windows XP, this path points to C:\Documents and Settings\All Users\Application 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} \AppData\Local\VirtualStore\并在那里执行所有操作。 。结果,由于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}\AppData\Local\VirtualStore\ 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 文件夹具有共享的读取访问权限,没有共享的写入访问权限。您当然可以在安装过程中更改文件夹的权限,但是我认为这与Microsoft的意图相反。
有关其他有用的链接,请参见其他问题

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

Microsoft认为应该如何做。 / a>

How Microsoft thinks it should be done.

这篇关于如何写到通用的Application Data文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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