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

📄 nativeregistry.cs

📁 POCKET PC,照片管理系统!提供了真正意义上的目录打开功能
💻 CS
字号:
using System;
using System.Runtime.InteropServices;

namespace Addot.Internals
{
	internal sealed class NativeRegistry
	{
        #region --- Registry Windows Platform constants ---
        internal enum RootKey : uint 
		{
			HKEY_CLASSES_ROOT = 0x80000000, 
			HKEY_CURRENT_USER = 0x80000001, 
			HKEY_LOCAL_MACHINE = 0x80000002,
			HKEY_USERS = 0x80000003 
		} 

		internal enum KeyDisposition : int 
		{
			REG_CREATED_NEW_KEY = 1, 
			REG_OPENED_EXISTING_KEY = 2 
		} 

		internal enum KeyType : int
		{
			REG_SZ = 1,
			REG_EXPAND_SZ = 2,
			REG_BINARY = 3,
			REG_DWORD = 4,
		}
        internal static readonly int ERROR_SUCCESS = 0;
        #endregion

        #region --- Registry P/Invokes functions ---
		[DllImport("coredll.dll", EntryPoint="RegOpenKeyEx")] 
		public static extern int RegOpenKeyEx(uint hKey,
			string lpSubKey, int ulOptions, int samDesired, ref uint phkResult); 

		[DllImport("coredll", EntryPoint="RegCreateKeyEx")] 
		public static extern int RegCreateKeyEx(uint
			hKey, string lpSubKey, int lpReserved, string lpClass, int dwOptions,
			int samDesired, ref int lpSecurityAttributes, ref uint phkResult, 
			out KeyDisposition lpdwDisposition); 

		[DllImport("coredll.dll", EntryPoint="RegEnumKeyEx")]
		public static extern int RegEnumKeyEx(uint hKey,
			int iIndex, 
			byte[] sKeyName, ref int iKeyNameLen, 
			int iReservedZero,
			byte[] sClassName, ref int iClassNameLen, 
			int iFiletimeZero);

		[DllImport("coredll.dll", EntryPoint="RegEnumValue")]
		public static extern int RegEnumValue(uint hKey,
			int iIndex, byte[] sValueName, 
			ref int iValueNameLen, int
			iReservedZero, ref KeyType iType, 
			ref byte[] byData, ref int iDataLen);

		[DllImport("coredll.dll", EntryPoint="RegQueryInfoKey")]
		public static extern int RegQueryInfoKey(uint
			hKey, char[] lpClass, ref int lpcbClass, 
			int reservedZero, ref int cSubkey, ref
			int iMaxSubkeyLen, ref int lpcbMaxSubkeyClassLen,
			ref int cValueNames, ref int
			iMaxValueNameLen, ref int iMaxValueLen, int securityDescriptorZero, int
			lastWriteTimeZero);

		[DllImport("coredll.dll", EntryPoint="RegQueryValueEx")] 
		public static extern int RegQueryValueEx(uint
			hKey, string lpValueName, int lpReserved, 
			ref KeyType lpType, byte[] lpData,
			ref int lpcbData); 

		[DllImport("coredll.dll", EntryPoint="RegSetValueExW")] 
		public static extern int RegSetValueEx(uint
			hKey, string lpValueName, int lpReserved, 
			KeyType lpType, byte[] lpData, int lpcbData); 

		[DllImport("coredll.dll", EntryPoint="RegCloseKey")] 
		public static extern int RegCloseKey(uint hKey);

		[DllImport("coredll.dll", EntryPoint="RegDeleteKey")]
		public static extern int RegDeleteKey(uint hKey,
			string keyName);

		[DllImport("coredll.dll", EntryPoint="RegDeleteValue")]
		public static extern int RegDeleteValue(uint
			hKey, string valueName);

        [DllImport("coredll.dll", EntryPoint="RegFlushKey")]
        public static extern int RegFlushKey(uint hKey);

        #endregion
	}
}

⌨️ 快捷键说明

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