News | Articles | Libraries | Developer Tools | Books | Forum Links | Search   
Sections:
 

Retrieving Owner Information on Pocket PC

By Nicholas Tsipanov, October 31, 2001.
Print version

Preface

This short article explains how you can retrieve Owner Information provided by the owner of Pocket PC from Owner Information dialog with eMbedded Visual C++.

Who does own this device?

Microsoft provided a GUI feature "User Information" to facilitate storing info about the device owner. This could help in cases like device loss or can be used in registration dialog. If you are creating an application that may get benefit from this info you may want to have a way to retrieve it.

There's no special API on Pocket PC to get the information that the user provided about himself. If the user entered any information into appropriate fields of Owner Information applet then it is stored in two binary registry values under [HKCU\ControlPanel\Owner] key: the "Notes" value contains notes that user wanted to add to information about himself and the "Owner" value contains everything else : name, email, phone, company and address.

To retrieve this information you should query binary value from the registry into a temporary buffer and initialize string values from that buffer.

Note: If the user didn't provide any information about himself then the corresponding registry values do not exist! You have to bear this in mind to avoid access violation issues in your code.

There is a sample code below that initialises some class CString member values with Owner Information items.

DWORD dwDisposition; RegCreateKeyEx( HKEY_CURRENT_USER, TEXT("\\ControlPanel\\Owner"), 0, NULL, 0, 0, NULL, &m_hKey, &dwDisposition); DWORD dwType = REG_BINARY; DWORD dwOwnerSize = 0x300 ; WCHAR *Owner = new WCHAR[dwOwnerSize / 2]; memset(Owner, 0, dwOwnerSize); if (RegQueryValueEx( m_hKey, TEXT("Owner"), 0, &dwType, (PBYTE)Owner, &dwOwnerSize ) == ERROR_SUCCESS) { m_strName = (LPCTSTR) Owner; m_strCompany = (LPCTSTR) (Owner + 0x24); m_strAddress = (LPCTSTR) ( Owner + 0x48); m_strTelephone = (LPCTSTR) ( Owner + 0x102); m_strEmail = (LPCTSTR) (Owner + 0x11B); } DWORD dwNotesSize = 0x200 ; WCHAR *Notes = new WCHAR[dwNotesSize / 2]; memset(Notes, 0, dwNotesSize); if (RegQueryValueEx( m_hKey, TEXT("Notes"), 0, &dwType, (PBYTE)Notes, &dwNotesSize ) == ERROR_SUCCESS) { m_strNotes = (LPCTSTR) Notes; }

You can download a bit more functional example - ownerinfo.zip (2 Kb).

Conclusion

Since there's no special API to get the owner information then the direct access to registry values may be not portable on future versions of Pocket PC. However these values didn't change on Pocket PC 2002 yet. This is not documented by Microsoft so far and you should keep your fingers crossed if you are stuck on this way of retrieving user info.

Related resources:

Discuss

Discuss this article. Here you can write your comments and read comments of other developers.
Rate this article:     Poor Excellent    
 12345 
© 2001-2005 Pocket PC Developer Network, a division of Spb Software House