📄 winregce.cs
字号:
//-----------------------------------------------------------------------------
// Code from _Programming the .NET Compact Framework with C#_
// and _Programming the .NET Compact Framework with VB_
// (c) Copyright 2002-2004 Paul Yao and David Durant.
// All rights reserved.
//-----------------------------------------------------------------------------
using System;
using System.Runtime.InteropServices;
using 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 : uint
{
HKEY_CLASSES_ROOT = 0x80000000,
HKEY_CURRENT_USER = 0x80000001,
HKEY_LOCAL_MACHINE = 0x80000002,
HKEY_USERS = 0x80000003,
HKEY_PERFORMANCE_DATA = 0x80000004,
HKEY_PERFORMANCE_TEXT = 0x80000050,
HKEY_PERFORMANCE_NLSTEXT = 0x80000060,
HKEY_CURRENT_CONFIG = 0x80000005,
}
public enum REGDISP
{
REG_CREATED_NEW_KEY = 0x1,
REG_OPENED_EXISTING_KEY = 0x2,
}
public enum REGTYPE : int
{
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,
}
[DllImport("CoreDLL.DLL")]
public static extern int
RegCloseKey(IntPtr hKey);
[DllImport("CoreDLL.DLL")]
public static extern int
RegOverridePredefKey(IntPtr hKey, IntPtr hNewHKey);
[DllImport("CoreDLL.DLL")]
public static extern int
RegOpenUserClassesRoot(IntPtr hToken, int dwOptions, int samDesired, IntPtr phkResult);
[DllImport("CoreDLL.DLL")]
public static extern int
RegOpenCurrentUser(int samDesired, IntPtr phkResult);
[DllImport("CoreDLL.DLL")]
public static extern int
RegDisablePredefinedCache();
[DllImport("CoreDLL.DLL")]
public static extern int
RegConnectRegistry(string lpMachineName,IntPtr hKey, IntPtr phkResult);
[DllImport("CoreDLL.DLL")]
public static extern int
RegCreateKey(IntPtr hKey, string lpSubKey, IntPtr phkResult);
[DllImport("CoreDLL.DLL")]
public static extern int
RegCreateKeyEx(IntPtr hKey, string lpSubKey, int Reserved, string lpClass, int dwOptions, int samDesired, IntPtr lpSecurityAttributes, ref IntPtr phkResult, ref WinRegCE.REGDISP lpdwDisposition);
[DllImport("CoreDLL.DLL")]
public static extern int
RegDeleteKey(IntPtr hKey, string lpSubKey);
[DllImport("CoreDLL.DLL")]
public static extern int
RegDeleteValue(IntPtr hKey, string lpValueName);
[DllImport("CoreDLL.DLL")]
public static extern int
RegEnumKey(IntPtr hKey, int dwIndex, string lpName, int cbName);
[DllImport("CoreDll.DLL")]
public static extern int
RegEnumKeyEx(IntPtr hKey, int dwIndex, string lpName, ref int lpcbName, int lpReserved, string lpClass, ref int lpcbClass, int lpftLastWriteTime);
[DllImport("CoreDLL.DLL")]
public static extern int
RegEnumValue(IntPtr hKey, int dwIndex, string lpValueName, ref int lpcbValueName, ref int lpReserved, ref int lpType, ref byte lpData, ref int lpcbData);
[DllImport("CoreDLL.DLL")]
public static extern int
RegLoadKey(IntPtr hKey, string lpSubKey, string lpFile);
[DllImport("CoreDLL.DLL")]
public static extern int
RegNotifyChangeKeyValue(IntPtr hKey, int bWatchSubtree, int dwNotifyFilter, IntPtr hEvent, int fAsynchronus);
[DllImport("CoreDLL.DLL")]
public static extern int
RegOpenKey(IntPtr hKey, string lpSubKey, IntPtr phkResult);
[DllImport("CoreDll.DLL")]
public static extern int
RegOpenKeyEx(IntPtr hKey, string lpSubKey, int ulOptions, int samDesired, ref IntPtr phkResult);
[DllImport("CoreDLL.DLL")]
public static extern int
RegQueryValue(IntPtr hKey, string lpSubKey, string lpValue, ref int lpcbValue);
// System.IntPtr version
[DllImport("CoreDLL.DLL")]
public static extern int
RegQueryValueEx(IntPtr hKey, string lpValueName,
int Res1, ref REGTYPE lpType,
IntPtr iptrData, ref int lpcbData);
// System.StringBuilder version
[DllImport("CoreDLL.DLL")]
public static extern int
RegQueryValueEx(IntPtr hKey, string lpValueName,
int Res1, ref REGTYPE lpType,
StringBuilder strData,
ref int lpcbData);
// System.int version
[DllImport("CoreDLL.DLL")]
public static extern int
RegQueryValueEx(IntPtr hKey, string lpValueName,
int Res1, ref REGTYPE lpType,
ref int piData, ref int lpcbData);
[DllImport("CoreDLL.DLL")]
public static extern int
RegReplaceKey(IntPtr hKey, string lpSubKey, string lpNewFile, string lpOldFile);
[DllImport("CoreDLL.DLL")]
public static extern int
RegRestoreKey(IntPtr hKey, string lpFile, int dwFlags);
[DllImport("CoreDLL.DLL")]
public static extern int
RegSaveKey(IntPtr hKey, string lpFile, IntPtr lpSecurityAttributes);
[DllImport("CoreDLL.DLL")]
public static extern int
RegSetValue(IntPtr hKey, string lpSubKey, int dwType, string lpData, int cbData);
// System.IntPtr version
[DllImport("CoreDLL.DLL")]
public static extern int
RegSetValueEx(IntPtr hKey, string lpValueName,
int Res1, REGTYPE dwType,
ref IntPtr lpData, int cbData);
// System.int version
[DllImport("CoreDLL.DLL")]
public static extern int
RegSetValueEx(IntPtr hKey, string lpValueName,
int Res1, REGTYPE dwType,
ref int piData, int cbData);
// System.string version
[DllImport("CoreDLL.DLL")]
public static extern int
RegSetValueEx(IntPtr hKey, string lpValueName,
int Res1, REGTYPE dwType,
string strData, int cbData);
[DllImport("CoreDLL.DLL")]
public static extern int
RegUnLoadKey(IntPtr hKey, string lpSubKey);
[DllImport("CoreDLL.DLL")]
public static extern int
RegSaveKeyEx(IntPtr hKey, string lpFile, IntPtr lpSecurityAttributes, int Flags);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -