Hey there

so this program im building needs to read the info from LocalMachine\\SYSTEM\CurrentControlSet\\Control\\ComputerName\\ComputerName\\

within that folder i need to get the data from the string value called "ComputerName" I've tried a lot of ways to get this within c# but with no success im afraid :/ I'm just ending up with an error saying "Object reference not set to an instance of an object"

Any idea how i could do this? :/

Kind Regards
-Jazerix

If all you need is the Computer name, I suggest you use Environment.MachineName As for your error, when you try and open a registry key, if null is returned it means that it couldn't open the key. This could be due to the fact it couldn't find the key or that you don't have permission to access the key.

The null error could be because the key name is incorrect.
Assuming that you cut & pasted the key name then you need to add a second \ after SYSTEM.

v
LocalMachine\\SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ComputerName\\

first of all, i didnt copy anything :P
the thing is, i already know how to get the name plus change it, the thing is, i need a label to say that the current name of the manchine has changed to something else and you need to reboot in order to change it fully.

So when you change the computer name, the active computer name will change when you restart the computer.

Example: you computer is named 1 you change it to 2
the active computer name will remain 1 until you restart your computer, but the computer name will change to 2

so if my program can detect that active computer name and computer name is different it means that it has to reboot, so i can add a line: Reboot for effect or something like that.

Im sorry if this wasnt well written as my english is not the best :/
thank you for your answers :D

Are you saying that the original problem is now solved?
If so then please mark the thread as solved.
If you still have a problem then post a code snippet and I'll try to help.

no its not, i still cant get it working :/

You are going to need to change the security permissions of your assembly. Read this on how to do so.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.