"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

Comments

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

Wednesday, December 05, 2007 11:45 PM by Bill

Hello, nice site look this:

2girls1cup-video.blogspot.com chinga tu madre

2girls1cup-video.blogspot.com chinga tu madre

2girls1cup-video.blogspot.com chinga tu madre

2girls1cup-video.blogspot.com chinga tu madre

2girls1cup-video.blogspot.com chinga tu madre

2girls1cup-video.blogspot.com chinga tu madre

2girls1cup-video.blogspot.com chinga tu madre

2girls1cup-video.blogspot.com chinga tu madre

2girls1cup-video.blogspot.com chinga tu madre

2girls1cup-video.blogspot.com chinga tu madre

End ^) See you

The leading UI suite for ASP.NET - Telerik radControls
Outstanding performance. Full ASP.NET AJAX support. Nearly codeless development.