C
C#2y 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
ero2y ago
I'm gonna assume "what" is not a real name lol
2yxle
2yxleOP2y ago
it isnt. it is just a test
ero
ero2y ago
You should provide more details
2yxle
2yxleOP2y 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
ero2y ago
Great, thanks. You just posted the exact same thing as in the original message That really helped get more detail
2yxle
2yxleOP2y ago
wdym, i explained what the button should do, but it doesnt work
ero
ero2y ago
What does "doesn't work", mean
2yxle
2yxleOP2y ago
it doesnt change the value
ero
ero2y ago
From what, how are you checking this Are you getting an error How are you testing this
2yxle
2yxleOP2y ago
nope no errors
ero
ero2y 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
2yxleOP2y 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
ero2y ago
. .
2yxle
2yxleOP2y ago
using registry editor to see if the value changes the output is clean, no errors
ero
ero2y ago
Are you testing your app with elevated rights
2yxle
2yxleOP2y ago
yes, i have it run as an administrator
ero
ero2y ago
Why are you using Registry.SetVakue instead of Registry.LocalMachine.SetValue
2yxle
2yxleOP2y ago
oh
2yxle
2yxleOP2y ago
it gives an error
ero
ero2y ago
Then look up how to fix it
2yxle
2yxleOP2y 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
phaseshift2y ago
Oh, you made a new thread for the same thing 😕 btw, did you ever verify that your code is actually getting hit?
2yxle
2yxleOP2y 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
Accord2y 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
2yxleOP2y ago
not resolve yet
ero
ero2y 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
2yxleOP2y ago
I have no idea why the value for mine doesn’t change
ero
ero2y ago
jcotton42
jcotton422y ago
oh wait I might know @2yxle print out System.Environment.Is64BitProcess and System.Environment.Is64BitOperatingSystem
2yxle
2yxleOP2y ago
Alr thx, I’ll try it out later
jcotton42
jcotton422y 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
2yxleOP2y ago
Thank you
Accord
Accord2y 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.
Want results from more Discord servers?
Add your server