Skip to main content

Past Blast

Featured Products

Stay in touch using the DEVBUSS RSS feeds.
 

News

Retrieve the Pocket PC Owner Information Using eVB

Written by Derek Mitchell  [author's bio]  [read 24180 times]
Edited by Derek

Page 1 

Sometimes it is useful to pre-fill user information, for example in registration screens. The Pocket PC owner information resides in the Windows CE registry in following key '\HKEY_CURRENT_USER\ControlPanel\Owner'. To access this information from eVB we will use three API calls; RegOpenKeyEx to open the specified key, RegQueryValueEx to read the sub-key value and RegCloseKey to clean up.

1) Open a new eVB project and add a Command button to the form.

2) Add the following code to the Form

Option Explicit
Public Declare Function RegOpenKeyEx Lib "Coredll" Alias "RegOpenKeyExW" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long

Public Declare Function RegQueryValueEx Lib "Coredll" Alias "RegQueryValueExW" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long

Public Declare Function RegCloseKey Lib "Coredll" (ByVal hKey As Long) As Long
Const ERROR_SUCCESS = &O0
Const HKEY_CURRENT_USER = &H80000001

3) Add the following code to the Command button

Dim lngSize As Long, hlngSubKey As Long
Dim lngType As Long, lngResult As Long
Dim RegData As String

lngSize = 256
RegData = String(lngSize, 0)

'Handle (hlngSubKey) to the "\ControlPanel\Owner" key
lngResult = RegOpenKeyEx(HKEY_CURRENT_USER, "\ControlPanel\Owner", 0, 0, hlngSubKey)

'Read the "Owner" info frm open registry key
lngResult = RegQueryValueEx(hlngSubKey, "Owner", 0, lngType, RegData, lngSize)

MsgBox RegData, vbOKOnly, "PPC Owner"

'Release the key handle
lngResult = RegCloseKey(hlngSubKey)

4) Run the project and tap the Command button. You will see a message box with the results of the API calls reading the owner information from the PPC registry.

4/29/2001 Update

There is more information related to reading the Pocket PC owner information in this article.