The type of the value object did not match the specified RegistryValuekind or the object could not properly converted Registry.SetValue c#

huangapple go评论69阅读模式
英文:

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);

huangapple
  • 本文由 发表于 2023年5月10日 15:34:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76215969.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定