Get the computer’s registered owner and organization in C#

[registered owner]

In Windows 98, the system’s registered owner and company name is stored in the following Registry keys:

SOFTWARE\Microsoft\Windows\CurrentVersion\RegisteredOwner
SOFTWARE\Microsoft\Windows\CurrentVersion\RegisteredOrganization

In Windows NT and later, the registered owner and company is stored in the following keys:

SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredOwner
SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredOrganization

This example uses the following code to get the information from the Registry and display it.

private void Form1_Load(object sender, EventArgs e)
{
    object owner_string = "", company_string = "";
    OperatingSystem os_info = System.Environment.OSVersion;
    if (os_info.Platform == PlatformID.Win32Windows)
    {
        // Windows 98?
        owner_string = RegistryTools.GetRegistryValue(
            Registry.LocalMachine,
            @"SOFTWARE\Microsoft\Windows\CurrentVersion\",
            "RegisteredOwner", "Unknown");
        company_string = RegistryTools.GetRegistryValue(
            Registry.LocalMachine,
            @"SOFTWARE\Microsoft\Windows\CurrentVersion\",
            "RegisteredOrganization", "Unknown");
    }
    else if (os_info.Platform == PlatformID.Win32NT)
    {
        // Windows NT.
        owner_string = RegistryTools.GetRegistryValue(
            Registry.LocalMachine,
            @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\",
            "RegisteredOwner", "Unknown");
        company_string = RegistryTools.GetRegistryValue(
            Registry.LocalMachine,
            @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\",
            "RegisteredOrganization", "Unknown");
    }

    txtOwner.Text = owner_string.ToString();
    txtCompany.Text = company_string.ToString();
}

The code checks the operating system platform to see which Registry keys it should look at and then uses the RegistryTools class’s GetRegistryValue method to get the values.

For information about the GetRegistryValue method, see the example Read Registry values (to get the desktop icon size) in C#.

Note: If you need to change the registered owner and organization, you can use RegEdit to change the appropriate Registry keys.


Download Example   Follow me on Twitter   RSS feed   Donate




This entry was posted in registry, system and tagged , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *