Changing RegisteredOwner & Organization

This tutorial will explain about how to change RegisteredOwner and RegisteredOrganization on your computer. RegisteredOwner Organization and we can see in the Control Panel - System, and in part to Registerd. To change the RegisteredOwner "manually" (through the registry editor) you can see here. 

The first step before manipulating the value in the registry is to notify the first key that will be accessed. How to change the properties RootKey. The contents of this property is HKey_Classes_Root, HKey_Current_User, HKey_Local_Machine, or HKey_Users. By default the value of this property is HKey_Current_User, so if you do not fill the property, and Delphi will be considered as HKey_Current_User.



1.      MyReg : TRegistry;

2.      begin

3.      MyReg := TRegistry.Create;

4.      MyReg.RootKey := HKey_Local_Machine;

5.      ……..

6.      MyReg.Free;

7.      end;


The second step is to open the subkey to be manipulated, that is the way to call the function OpenKey. OpenKey function declaration is as follows:

function OpenKey(const Key: string; CanCreate: Boolean): Boolean;

There are two parameters that must be filled. Bertipe The first parameter is a string that subkey to be opened. Bertipe while the second parameter boolean, which will determine whether the subkey will be created or not. When the parameter value is true, then the Delphi will create a subkey in the registry if there is not. Conversely if the value false, subkey will not be made even if the registry does not exist yet. OpenKey this function will return true if the initialization value and the successful return false if failed. 

To change RegisteredOwner, the subkey is: \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ 

So, the code we should write is:

1.      MyReg.RootKey := HKEY_LOCAL_MACHINE;

2.      MyReg.OpenKey := ('\SOFTWARE\Microsoft\Windows\ CurrentVersion'false);


After the steps above, then you can read or write data to the registry. To read the data on the registry you can use ReadString, ReadInteger, etc. (read the Help file in its Delphi). While writing data to the registry using WriteString, WriteInteger, etc.. 

Code below shows how to read data on the registry, which results in the written component Edit1.


1.      Edit1.Text := MyReg.ReadString ('RegisteredOwner');

2.      Edit2.Text := MyReg.ReadString ('RegisteredOrganization');


Meanwhile, write data to the registry using the following ways:

1.      reg.WriteString ('RegisteredOwner', Edit1.Text);

2.      reg.WriteString ('RegisteredOrganization', Edit2.Text);


Code read as follows:

unit Unit1;

1.      interface


3.      uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, registry;


5.      type

6.      TForm1 = class(TForm)

7.      Edit1: TEdit;

8.      Edit2: TEdit;

9.      Label1: TLabel;

10.  Label2: TLabel;

11.  Button1: TButton;

12.  Button2: TButton;

13.  procedure Button2Click(Sender: TObject);

14.  procedure FormCreate(Sender: TObject);

15.  procedure Button1Click(Sender: TObject);

16.  private

17.  { Private declarations }

18.  public

19.  { Public declarations }

20.  end;


22.  var

23.  Form1: TForm1;

24.  reg : TRegistry;


26.  implementation

27.  {$R *.DFM}


29.  procedure TForm1.Button2Click(Sender: TObject);

30.  begin

31.  Close// menutup form

32.  end;


34.  procedure TForm1.FormCreate(Sender: TObject);

35.  begin

36.  reg := TRegistry.Create;

37.  reg.RootKey := HKEY_LOCAL_MACHINE;

38.  reg.OpenKey ('\Software\Microsoft\Windows\CurrentVersion'false);

39.  Edit1.Text := reg.ReadString ('RegisteredOwner');

40.  Edit2.Text := reg.ReadString ('RegisteredOrganization');

41.  reg.Free;

42.  end;


44.  procedure TForm1.Button1Click(Sender: TObject);

45.  begin

46.  reg := TRegistry.Create;

47.  reg.RootKey := HKEY_LOCAL_MACHINE;

48.  reg.OpenKey ('\Software\Microsoft\Windows\CurrentVersion'false);

49.  reg.WriteString ('RegisteredOwner', Edit1.Text);

50.  reg.WriteString ('RegisteredOrganization', Edit2.Text);

51.  reg.Free;

52.  end;


54.  end.