NAVmoble - the pocket-sized ERP
Optimized for Microsoft Dynamics NAV and Windows Mobile powered devices

Tuesday, July 24, 2007

"How To" Series: Reading Device Owner Information on Windows Mobile

I noticed recently, that some guys asked(in the forums) how to read the device owner information from .NET Compact Framework.

The Device Owner information may be obtained from the device's registry. It is stored under the following registry key: HKEY_CURRENT_USER\ControlPanel\Owner

Note that, this key may be missing on a fresh device. The key is populated after the owner sets his/her information.

The registry key HKEY_CURRENT_USER\ControlPanel\Owner has two interesting values:
"Owner" and "Owner Notes". These values holds binary data.
The "Owner" value contains the following owner information attributes: Name, Company, Phone, E-mail, Address. The "Owner Notes" value contains the Notes of the owner :)
Reading Owner notes is simple like:
RegistryKey key = Registry.CurrentUser.OpenSubKey("ControlPanel\\Owner");
byte[] data = key.GetValue("Owner Notes") as byte[];
string notes = UnicodeEncoding.Unicode.GetString(data, 0, data.Length).TrimEnd('\0');

The tricky part is to "decode" the "Owner" binary data, which contains multiple fixed-length values. In order to deal with it , we have to know the exact length of every device owner attribute:

  • Name: 72 bytes
  • Company: 72 bytes
  • Address: 372 bytes
  • Phone: 48 bytes
  • Email: 74 bytes

So, reading the "Owner" info is easy as:
RegistryKey key = Registry.CurrentUser.OpenSubKey("ControlPanel\\Owner");
byte[] data = key.GetValue("Owner") as byte[];
string name = UnicodeEncoding.Unicode.GetString(data,0,72).TrimEnd('\0');
string company = UnicodeEncoding.Unicode.GetString(data,72,72).TrimEnd('\0');
string address = UnicodeEncoding.Unicode.GetString(data, 144, 372).TrimEnd('\0');
string phone = UnicodeEncoding.Unicode.GetString(data, 516, 48).TrimEnd('\0');
string email = UnicodeEncoding.Unicode.GetString(data, 566, 74).TrimEnd('\0');

You may obtain the full source code from here


Anonymous said...

Thank you so much!!
I was trying to create a provision XML that has all the Owner Info stored in unicode base64. I had no clue how Owner Information is stored and with your post it was much easier =).

Огромное спасибо!

Anonymous said...


Thanks for your blog. Really helped me out.

One question though. Do you know where the option to show the Owner details on Windows Start up is found?

i.e. If you go to the Option tab on the owners screen, and select either Display Owner Information or Display Notes on Windows start up. Where is this value stored in registry?

Many thanks


Anonymous said...

[HKEY_CURRENT_USER\ControlPanel\Owner] hive

Keys [Owner Notes] and [Owner] 2nd to last bit, set to 01 to show on startup.

Anonymous said...

how does one set the owner data programmatically ?

andyNguyen said...

Thanks so much for the trick of the changing the last 2nd bit 00 => 01 to show/ unshow the Owner Ifo Screen on display