在windows8中,如果你更改注册表,这些更改将不会立即出现在磁盘上。在这里可以找到对这种行为的解释:http://support.microsoft.com/kb/2784761
如果要更改此行为,可以使用RegFlushKey函数
问题是如何使用它?私有静态只读IntPtr HKEY_LOCAL_MACHINE =新IntPtr(-2147483646);
[DllImport("advapi32.dll", SetLastError = true)]
public static extern int RegFlushKey(IntPtr hKey);
static void Main(string[] args)
{
RegFlushKey(HKEY_LOCAL_MACHINE);
}这就是我试图实现它的方式,但在此之后,代码注册表的更改将不会出现在文件系统上。
如果我做错了什么,请指点我
发布于 2014-02-25 23:15:09
[DllImport("Advapi32.dll", EntryPoint = "RegFlushKey")]
public static extern int RegFlushKey(IntPtr hKey);
const UInt32 HKEY_CLASSES_ROOT = 0x80000000;
const UInt32 HKEY_CURRENT_USER = 0x80000001;
const UInt32 HKEY_LOCAL_MACHINE = 0x80000002;
const UInt32 HKEY_USERS = 0x80000003;
public static void CommitRegistry()
{
IntPtr hkeyLocalMachine = new IntPtr(unchecked((int)HKEY_LOCAL_MACHINE));
RegFlushKey(hkeyLocalMachine);
}https://stackoverflow.com/questions/16776305
复制相似问题