⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yaodurant.win32.winregce.vb

📁 Programming the .NET Compact Framework with vb 源代码
💻 VB
字号:
' YaoDurant.Win32.WinRegCE.vb - Generic wrappers for 
' Win32 API registry functions.
'
' Code from _Programming the .NET Compact Framework with C#_
' and _Programming the .NET Compact Framework with VB_
' (c) Copyright 2002-2003 Paul Yao and David Durant. 
' All rights reserved.

Imports System
Imports System.Runtime.InteropServices
Imports System.Text


'  WinRegCE:  
'     A library class that wraps the registry access
'        routines specified in WinReg.H.  Overloaded
'        versions of the reading and writing routines
'        are provided.
Namespace YaoDurant.Win32

   Public Class WinRegCE

      ' Mostly generated by PInvoke Wizard (v 1.0) from
      '    The Paul Yao Company http://www.paulyao.com 

      Public Enum HKEY
         HKEY_CLASSES_ROOT = &H80000000
         HKEY_CURRENT_USER = &H80000001
         HKEY_LOCAL_MACHINE = &H80000002
         HKEY_USERS = &H80000003
         HKEY_PERFORMANCE_DATA = &H80000004
         HKEY_PERFORMANCE_TEXT = &H80000050
         HKEY_PERFORMANCE_NLSTEXT = &H80000060
         HKEY_CURRENT_CONFIG = &H80000005
      End Enum

      Public Enum REGDISP
         REG_CREATED_NEW_KEY = &H1
         REG_OPENED_EXISTING_KEY = &H2
      End Enum

      Public Enum REGTYPE
         REG_NONE = 0
         REG_SZ = 1
         REG_EXPAND_SZ = 2
         REG_BINARY = 3
         REG_DWORD = 4
         REG_DWORD_LITTLE_ENDIAN = 4
         REG_DWORD_BIG_ENDIAN = 5
         REG_LINK = 6
         REG_MULTI_SZ = 7
         REG_RESOURCE_LIST = 8
      End Enum

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegCloseKey( _
           ByVal hKey As IntPtr _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegOverridePredefKey( _
           ByVal hKey As IntPtr _
         , ByVal hNewHKey As IntPtr _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegOpenUserClassesRoot( _
         ByVal hToken As IntPtr _
         , ByVal dwOptions As Integer _
         , ByVal samDesired As Integer _
         , ByVal phkResult As IntPtr _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegOpenCurrentUser( _
         ByVal samDesired As Integer _
         , ByVal phkResult As IntPtr _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegDisablePredefinedCache( _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegConnectRegistry( _
         ByVal lpMachineName As String _
         , ByVal hKey As IntPtr _
         , ByVal phkResult As IntPtr _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegCreateKey( _
           ByVal hKey As IntPtr _
         , ByVal lpSubKey As String _
         , ByVal phkResult As IntPtr _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegCreateKeyEx( _
           ByVal hKey As IntPtr _
         , ByVal lpSubKey As String _
         , ByVal Reserved As Integer _
         , ByVal lpClass As String _
         , ByVal dwOptions As Integer _
         , ByVal samDesired As Integer _
         , ByVal lpSecurityAttributes As IntPtr _
         , ByRef phkResult As IntPtr _
         , ByRef lpdwDisposition As WinRegCE.REGDISP _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegDeleteKey( _
           ByVal hKey As IntPtr _
         , ByVal lpSubKey As String _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegDeleteValue( _
           ByVal hKey As IntPtr _
         , ByVal lpValueName As String _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegEnumKey( _
           ByVal hKey As IntPtr _
         , ByVal dwIndex As Integer _
         , ByVal lpName As String _
         , ByVal cbName As Integer _
         ) As Integer
      End Function

      <DllImport("CoreDll.DLL")> _
      Public Shared Function RegEnumKeyEx( _
           ByVal hKey As IntPtr _
         , ByVal dwIndex As Integer _
         , ByVal lpName As String _
         , ByRef lpcbName As Integer _
         , ByVal lpReserved As Integer _
         , ByVal lpClass As String _
         , ByRef lpcbClass As Integer _
         , ByVal lpftLastWriteTime As Integer _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegEnumValue( _
         ByVal hKey As IntPtr _
         , ByVal dwIndex As Integer _
         , ByVal lpValueName As String _
         , ByRef lpcbValueName As Integer _
         , ByRef lpReserved As Integer _
         , ByRef lpType As Integer _
         , ByRef lpData As Byte _
         , ByRef lpcbData As Integer _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegLoadKey( _
         ByVal hKey As IntPtr _
         , ByVal lpSubKey As String _
         , ByVal lpFile As String _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegNotifyChangeKeyValue( _
           ByVal hKey As IntPtr _
         , ByVal bWatchSubtree As Integer _
         , ByVal dwNotifyFilter As Integer _
         , ByVal hEvent As IntPtr _
         , ByVal fAsynchronus As Integer _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegOpenKey( _
           ByVal hKey As IntPtr _
         , ByVal lpSubKey As String _
         , ByVal phkResult As IntPtr _
         ) As Integer
      End Function

      <DllImport("CoreDll.DLL")> _
      Public Shared Function RegOpenKeyEx( _
           ByVal hKey As IntPtr _
         , ByVal lpSubKey As String _
         , ByVal ulOptions As Integer _
         , ByVal samDesired As Integer _
         , ByRef phkResult As IntPtr _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegQueryValue( _
         ByVal hKey As IntPtr _
         , ByVal lpSubKey As String _
         , ByVal lpValue As String _
         , ByRef lpcbValue As Integer _
         ) As Integer
      End Function

      '  System.IntPtr version
      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegQueryValueEx( _
           ByVal hKey As IntPtr _
         , ByVal lpValueName As String _
         , ByVal Res1 As Integer _
         , ByRef lpType As REGTYPE _
         , ByVal iptrData As IntPtr _
         , ByRef lpcbData As Integer _
         ) As Integer
      End Function

      '  System.StringBuilder version
      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegQueryValueEx( _
           ByVal hKey As IntPtr _
         , ByVal lpValueName As String _
         , ByVal Res1 As Integer _
         , ByRef lpType As REGTYPE _
         , ByVal strData As StringBuilder _
         , ByRef lpcbData As Integer _
         ) As Integer
      End Function

      '  System.Integer version
      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegQueryValueEx( _
           ByVal hKey As IntPtr _
         , ByVal lpValueName As String _
         , ByVal Res1 As Integer _
         , ByRef lpType As REGTYPE _
         , ByRef piData As Integer _
         , ByRef lpcbData As Integer _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegReplaceKey( _
         ByVal hKey As IntPtr _
         , ByVal lpSubKey As String _
         , ByVal lpNewFile As String _
         , ByVal lpOldFile As String _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegRestoreKey( _
         ByVal hKey As IntPtr _
         , ByVal lpFile As String _
         , ByVal dwFlags As Integer _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegSaveKey( _
         ByVal hKey As IntPtr _
         , ByVal lpFile As String _
         , ByVal lpSecurityAttributes As IntPtr _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegSetValue( _
           ByVal hKey As IntPtr _
         , ByVal lpSubKey As String _
         , ByVal dwType As Integer _
         , ByVal lpData As String _
         , ByVal cbData As Integer _
         ) As Integer
      End Function

      '  System.IntPtr version
      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegSetValueEx( _
           ByVal hKey As IntPtr _
         , ByVal lpValueName As String _
         , ByVal Res1 As Integer _
         , ByVal dwType As REGTYPE _
         , ByRef lpData As IntPtr _
         , ByVal cbData As Integer _
         ) As Integer
      End Function

      '  System.Integer version
      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegSetValueEx( _
         ByVal hKey As IntPtr _
         , ByVal lpValueName As String _
         , ByVal Res1 As Integer _
         , ByVal dwType As REGTYPE _
         , ByRef piData As Integer _
         , ByVal cbData As Integer _
         ) As Integer
      End Function

      '  System.String version
      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegSetValueEx( _
         ByVal hKey As IntPtr _
         , ByVal lpValueName As String _
         , ByVal Res1 As Integer _
         , ByVal dwType As REGTYPE _
         , ByVal strData As String _
         , ByVal cbData As Integer _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegUnLoadKey( _
         ByVal hKey As IntPtr _
         , ByVal lpSubKey As String _
         ) As Integer
      End Function

      <DllImport("CoreDLL.DLL")> _
      Public Shared Function RegSaveKeyEx( _
         ByVal hKey As IntPtr _
         , ByVal lpFile As String _
         , ByVal lpSecurityAttributes As IntPtr _
         , ByVal Flags As Integer _
         ) As Integer
      End Function
   End Class

End Namespace

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -