Skip to main content

Past Blast

Featured Products

Windows Mobile Developer Controls
Windows Mobile Developer Controls
Stay in touch using the DEVBUSS RSS feeds.
 

News

Windows Mobile Developer Controls
Sapphire Soltuions

eVB sample accessing the Pocket PC Windows CE Registry.

Written by Arnold Cota  [author's bio]  [read 33133 times]
Edited by Derek

Download the code

Page 1 

Sample code - eVB and the WINCE registry

Once you have downloaded the code above - fire up eVB and load the project. Very simply this code demonstrates how to create Windows CE registry keys, set their values and then retrieve those settings. The first screen you will see when you run the project will be the following blank screen:

To see how this works click on the 'Sample' button. A message box will then instruct you to tap the 'Create' button followed by the 'Save' button. In essence this will create the 'deBuzz\Tutorial' key with a SubKey of 'ArnCota' when the Create key is tapped and then save the value when the Save key is tapped. All very easy.

Now let's take a look at the code behind the Create button:

Private Sub cmdCreate_Click()
'-- Create New Key in Registry if user typed in a key
If Len(txtKey.Text) > 0 Then
  '-- Create Key in selected section
  CreateNewKey   cmbSection.ItemData(cmbSection.ListIndex),   txtKey.Text
End If
End Sub

This simply calls the CreateNewKey function, which resides in the mRegistry.bas module:

Public Function CreateNewKey(lSection As Long, _
sNewKeyName As String)
Dim hNewKey As Long '-- Handle to the new key
Dim lRetVal As Long '-- Result of the RegCreateKeyEx
'-- Create Registry Key
'-- If key already exists, nothing happens
lRetVal = RegCreateKeyEx(lSection, sNewKeyName, CLng(0), _
vbNullString, REG_OPTION_NON_VOLATILE, _
KEY_ALL_ACCESS, _
CLng(0), hNewKey, lRetVal)
'-- Return Handle to Key
CreateNewKey = hNewKey
'-- Close Registry Handle
RegCloseKey (hNewKey)
End Function

The rest of the funtions operate on a similar paradigm so it should be pretty easy to work out.