问题
I just want to be able to programmatically do what gpedit.msc
does. I'm trying to set the value of these keys to 1 and Update the Local Group Registry.
In gpedit.msc:
Local Computer Policy/Computer Configuration/Administrative Templates/System/Removable Storage Access
ValueName: All Removable Storage classes: Deny all access
Value: 1 (set this to 1)
Local Computer Policy/Computer Configuration/Administrative Templates/Windows Components/AutoPlay Policies
ValueName: Turn off Autoplay
Value: 1 ( set this to 1)
I think the key is to use IGroupPolicyObject
in C++. However, I can't find any documentation that I can wrap my head around.
My application needs to disable/enable all USB Access without having to reboot Windows 7.
回答1:
I think that these links will help you:
C/C++ with a fully described way to change a setting in LGPO: Pete's Blog - Programatically setting and applying Local Group Policies on Windows
C# code that alters LGPO object by ComImport mechanism Software Developer's Bytes - Group Policy Object via .NET\C#
来源:https://stackoverflow.com/questions/12926644/update-the-local-computer-policy-in-windows-7-with-igrouppolicyobject