英文:
The type of the value object did not match the specified RegistryValuekind or the object could not properly converted Registry.SetValue c#
问题
I am using Winforms on .NET 4.5, I try to set registry value.
This is my code:
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile", "NetworkThrottlingIndex", "ffffffff", RegistryValueKind.DWord);
and
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile", "NetworkThrottlingIndex", "0000000a", RegistryValueKind.DWord);
But this raised an error:
The type of the value object did not match the specified RegistryValuekind or the object could not properly converted
Please help me fix this.
英文:
I am using Winforms on .NET 4.5, I try to set registry value.
This is my code:
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile", "NetworkThrottlingIndex", "ffffffff", RegistryValueKind.DWord);
and
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile", "NetworkThrottlingIndex", "0000000a", RegistryValueKind.DWord);
But this raised an error :
> The type of the value object did not match the specified RegistryValuekind or the object could not properly converted
Please help me fix this.
答案1
得分: 1
I have to use QWORD instead of DWord, and not using string but actual value:
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile", "NetworkThrottlingIndex", 0xFFFFFFFF, RegistryValueKind.QWord);
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile", "NetworkThrottlingIndex", 0x0000000a, RegistryValueKind.QWord);
英文:
i have to use QWORD instead of DWord , and not using string but actual value :
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile", "NetworkThrottlingIndex", 0xFFFFFFFF, RegistryValueKind.QWord);
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile", "NetworkThrottlingIndex", 0x0000000a, RegistryValueKind.QWord);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论