Similar to Windows, WindowsProgramAnd driver settings are saved in the system registry. The organization of the wince registry is similar to that of the desktop system, including the following four root keys:
Hkey_class_root, including file extension information and COM Subsystem Configuration Information
HKEY_LOCAL_MACHINE, which contains system, driver, and application configuration information
HKEY_CURRENT_USER, which contains the configuration information of the current user
Hkey_user, which contains information of all users
Wince provides a series of APIs used to operate the Registry. Previously, the driver debugging assistant tool was implemented using these Apis. So how does VB. NET operate the registry? In fact, it is simpler. NET Compact framework provides registry and registrykey. You can use these two classes to conveniently read and write the registry.
The following describes how to modify the name and description of the wince device to read and write the registry using VB. NET. ReferenceCodeAs follows.
1 Imports Microsoft. Win32
2
3 Public Class Devname
4
5 Private Sub Buttonset_click ( Byval Sender As System. object, Byval E As System. eventargs) Handles Buttonset. Click
6 Dim HKLM As Registrykey = Registry. localmachine
7 Dim Subkey As Registrykey = HKLM. opensubkey ( " Ident " , True )
8 Subkey. setvalue ( " Name " , Textboxdevname. Text)
9 Subkey. setvalue ( " Desc " , Textboxdevdesc. Text)
10 End sub
11
12 Private Sub Buttonget_click ( Byval Sender As System. object, Byval E As System. eventargs) Handles Buttonget. Click
13 Dim HKLM As Registrykey = Registry. localmachine
14 Dim Subkey As Registrykey = HKLM. opensubkey ( " Ident " , False )
15 Textboxdevname. Text = Subkey. getvalue ( " Name " )
16 Textboxdevdesc. Text = Subkey. getvalue ( " Desc " )
17 End sub
18
19 Private Sub Buttonclear_click ( Byval Sender As System. object, Byval E As System. eventargs) Handles Buttonclear. Click
20 Textboxdevname. Text = ""
21 Textboxdevdesc. Text = ""
22 End sub
23 End Class
If the wince system supports the hive registry, you can also useRegistrykey. Flush () orRegistrykey. Close(), Refresh the modified content to the disk.