C
C#β€’3y ago
2yxle

❔ Doing a test DWORD, but sometimes the Dword value doesnt change:

I want to change the DWORD value when clicking the button, but it doesn't change. How do i resolve this issue? Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\AMD", "what", 1, RegistryValueKind.DWord);
33 Replies
ero
eroβ€’3y ago
I'm gonna assume "what" is not a real name lol
2yxle
2yxleOPβ€’3y ago
it isnt. it is just a test
ero
eroβ€’3y ago
You should provide more details
2yxle
2yxleOPβ€’3y ago
when i click a button, it should set the value what to 1, but it doesnt work. Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\AMD", "what", 1, RegistryValueKind.DWord); code is here
ero
eroβ€’3y ago
Great, thanks. You just posted the exact same thing as in the original message That really helped get more detail
2yxle
2yxleOPβ€’3y ago
wdym, i explained what the button should do, but it doesnt work
ero
eroβ€’3y ago
What does "doesn't work", mean
2yxle
2yxleOPβ€’3y ago
it doesnt change the value
ero
eroβ€’3y ago
From what, how are you checking this Are you getting an error How are you testing this
2yxle
2yxleOPβ€’3y ago
nope no errors
ero
eroβ€’3y ago
What kind of project is this What does the surrounding code look like Is there anything else disrupting it Like man any more detail would be good
2yxle
2yxleOPβ€’3y ago
public partial class testform : Form { public testform() { InitializeComponent(); } private void Apply_Click(object sender, EventArgs e) {
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\AMD", "what", 1, RegistryValueKind.DWord); } } } this is my test code, yet the value doesnt change when clicked
ero
eroβ€’3y ago
. .
2yxle
2yxleOPβ€’3y ago
using registry editor to see if the value changes the output is clean, no errors
ero
eroβ€’3y ago
Are you testing your app with elevated rights
2yxle
2yxleOPβ€’3y ago
yes, i have it run as an administrator
ero
eroβ€’3y ago
Why are you using Registry.SetVakue instead of Registry.LocalMachine.SetValue
2yxle
2yxleOPβ€’3y ago
oh
2yxle
2yxleOPβ€’3y ago
it gives an error
ero
eroβ€’3y ago
Then look up how to fix it
2yxle
2yxleOPβ€’3y ago
alr i have got a new line try { Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\AMD", "what", 1, RegistryValueKind.DWord); Console.WriteLine("Registry value changed successfully."); } catch (Exception ex) { Console.WriteLine("An error occurred while changing the registry value: " + ex.Message); } the value doesnt change to 1 still
phaseshift
phaseshiftβ€’3y ago
Oh, you made a new thread for the same thing πŸ˜• btw, did you ever verify that your code is actually getting hit?
2yxle
2yxleOPβ€’3y ago
yeah, i put a message box to show that it works, but the value doesnt change, but the message box will say that the registry has been applied
Accord
Accordβ€’3y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
2yxle
2yxleOPβ€’3y ago
not resolve yet
ero
eroβ€’3y ago
works fine for me btw literally this is my entire program
using Microsoft.Win32;

Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\AMD", "what", 1, RegistryValueKind.DWord);
using Microsoft.Win32;

Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\AMD", "what", 1, RegistryValueKind.DWord);
and it works
2yxle
2yxleOPβ€’3y ago
I have no idea why the value for mine doesn’t change
ero
eroβ€’3y ago
jcotton42
jcotton42β€’3y ago
oh wait I might know @2yxle print out System.Environment.Is64BitProcess and System.Environment.Is64BitOperatingSystem
2yxle
2yxleOPβ€’3y ago
Alr thx, I’ll try it out later
jcotton42
jcotton42β€’3y ago
if your app is running as 32-bit, it might be hitting WOW64 redirection in the proejct settings make sure "32-bit preferred" is not checked
2yxle
2yxleOPβ€’3y ago
Thank you
Accord
Accordβ€’3y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?