Reference code for reading and writing the registry using VB. NET under WinCE

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.