简体   繁体   English

Windows 7和8中的系统范围设置-注册表不再有用吗?

[英]System-wide setting in Windows 7 and 8 - Registry is no longer useful?

I want to track a setting system-wide on the target machine- it is a run time counter that keeps track of how many times my client runs my software. 我想跟踪目标机器上整个系统的设置-它是一个运行时计数器,用于跟踪客户端运行我的软件的次数。 I decided to put this value in the registry, but I really want to track how many times it is run for the whole system, not just for the current user account. 我决定将此值放在注册表中,但我真的想跟踪整个系统(而不只是当前用户帐户)运行该值的次数。

I would expect to use HKLM to track this at a machine level, but UAC doesn't like this nowdays. 我希望可以使用HKLM在计算机级别进行跟踪,但是UAC现在不喜欢这种情况。

Is there a correct way to read and write a setting that is machine-wide? 是否有正确的方法来读写机器范围内的设置?

HKLM isn't for this type of use (since Windows XP at least). HKLM不适用于这种类型的使用(至少从Windows XP开始)。

Use the %PROGRAMDATA% folder instead (which you can also get via the WinAPI function SHGetKnownFolderPath with FOLDERID_ProgramData ( SHGetFolderPath with CSIDL_APPDATA on Windows versions prior to Vista). It's specifically designed for application data that is global to all users of the machine. (On Windows 7, this is the C:\\ProgramData folder by default.) Your application should create a directory beneath there and store the counter information in a file in that location instead. 请改用%PROGRAMDATA%文件夹(您也可以通过WinAPI函数SHGetKnownFolderPathFOLDERID_ProgramDataSHGetFolderPathCSIDL_APPDATA在Vista之前的Windows版本上获得)。它专门用于对计算机所有用户都是全局的应用程序数据。 Windows 7,默认情况下为C:\\ProgramData文件夹。)您的应用程序应在该目录下创建一个目录,并将计数器信息存储在该位置的文件中。

(It also means you don't have to defeat the purpose of UAC by allowing public write access to the registry in inappropriate locations.) (这也意味着您不必通过允许在不适当的位置公开访问注册表来破坏UAC的目的。)

From Environment.SpecialFolder Enumeration : Environment.SpecialFolder枚举

CommonApplicationData The directory that serves as a common repository for application-specific data that is used by all users. CommonApplicationData该目录充当所有用户使用的特定于应用程序的数据的公共存储库。

Have a "CommonApplicationData\\Your Company Name\\Your Product Name" folder created in your setup program and change the ACL for the folder to allow limited user full control permissions (the inherited permission is read only for limited users). 在安装程序中创建一个“ CommonApplicationData \\您的公司名称\\您的产品名称”文件夹,并更改该文件夹的ACL以允许受限用户的完全控制权限(继承的权限仅对受限用户只读)。 You can do this via the LockPermissions MSI table, or if your setup program does not support LockPermissions, create a custom action to change the ACL. 您可以通过LockPermissions MSI表执行此操作,或者如果安装程序不支持LockPermissions,则创建一个自定义操作来更改ACL。

You also need to handle potential edit conflicts created by fast user switching. 您还需要处理由快速用户切换造成的潜在编辑冲突。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 与“系统级”媒体播放器互动 - Interact with “system-wide” media player 取消处理(取消注册)系统范围的“HotKey” - Unhandling (unregistering) a system-wide 'HotKey' 如何在C#中通过Windows资源管理器有效监视系统范围的“文件名更改事件” - How to monitor system-wide “file name change event” by windows explorer effectively in c# 是.net系统范围内的垃圾收集器还是应用程序范围内的垃圾收集器? - Is the garbage collector in .net system-wide or application-wide? 有没有一种方法可以禁用所有WPF应用程序的缩放比例,即使Windows的每个监视器或系统范围的缩放比例有所不同? - Is there a way to disable scaling for all the WPF application even if windows has some scale per monitor or system-wide scale? .NET系统范围内的EventWaitHandle名称允许的字符 - .NET system-wide EventWaitHandle name allowed characters 从DB处理队列时,系统范围互斥的替代方案? - alternatives to system-wide mutex when processing queue from DB? 是否可以定义在整个系统范围内使用的自定义URI方案? - Is possible to define custom URI scheme used system-wide? C#异步接收会导致系统范围的网络崩溃! - C# asynchronous receive causes system-wide network crash! 应用程序如何与系统范围的文本选择挂钩? - How can an app hook into text selection system-wide?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM