注册表操作的几个windows api

(转自:http://blog.sina.com.cn/s/blog_4e66c6cd01000bcu.html)

 键管理类:
 

RegCloseKey():关闭注册表键释放句柄。
    RegCloseKey(ByVal hKey As Long)
   
 参数:hKey--根键(或子键)句柄
    返回值:=0 成功     ≠0 失败

RegCreateKey():打开指定的注册表键,如果该键不存在则试图建立。
    RegCreateKey(ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long)
    参数:hKey--根键句柄    lpSubKey--子键的名称或路径    
         phkResult--若执行成功则该参数返回子键的句柄
    返回值:=0 成功     ≠0 失败

RegCreateKeyEx():同RegCreateKey()。

    RegCreateKeyEx(ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As SECURITY_ATTRIBUTES, phkResult As Long, lpdwDisposition As Long)


RegDeleteKey():删除注册表键,但不能删除根键。      
    RegDeleteKey(ByVal hKey As Long, ByVal lpSubKey As String)
    参数:hKey--键句柄     lpSubKey--子键名称或路径,如为""则删除hKey键
    返回值:=0 成功     ≠0 失败

RegDeleteKeyEx():同RegDeleteKeyEx()

RegOpenKey():获得注册表根键下子键的句柄。
    RegOpenKey(ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long)
    参数:hKey--根键句柄    lpSubKey--子键的名称或路径
         phkResult--若执行成功则该参数返回子键的句柄
    返回值:=0 成功     ≠0 失败

RegOpenKeyEx():同RegOpenKey()

        RegOpenKeyEx(ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long)

值管理类:

LONG RegQueryValueEx(
        HKEY hKey,      // 已打开的键的句柄
        LPTSTR lpValueName, // 要查询值的名称,传如""为查询键下的默认值
        LPDWORD lpReserved, // 保留,为0
        LPDWORD lpType,   // 查询的类型
        LPBYTE lpData,    // 数据存放的地址
        LPDWORD lpcbData   // 数据长度+1
      );

RegQueryValue() 与以上类似

  
LONG RegSetValueEx(
        HKEY hKey,      // 已打开的键的句柄
        LPCTSTR lpValueName, // 要查询值的名称,传如""为查询键下的默认值
        DWORD Reserved,   // 保留
        DWORD dwType,    // 变量的类型
        CONST BYTE *lpData, // 变量数据的地址
        DWORD cbData     // 变量的长度
      );


 

RegSetValue() 与以上类似


LONG RegDeleteValue(
        HKEY hKey,      // 要删除的键的句柄
        LPCTSTR lpValueName  // 要删除的名称
      );

LONG RegEnumValue(
        HKEY hKey,       // 要查询的已打开的键的句柄
        DWORD dwIndex,     // 读取名称的索引号
        LPTSTR lpValueName,   // 返回所读取的名称
        LPDWORD lpcbValueName, // 返回读取名称的长度,不含chr(0)
        LPDWORD lpReserved,   // 保留,为0
        LPDWORD lpType,     // 返回所读取的数据类型
        LPBYTE lpData,     // 返回所读取的数据`
        LPDWORD lpcbData    // 返回所读取的数据长度
     );
 
RegEnumKeyEx(
        HKEY hKey,     // 要列举的键的句柄
        DWORD dwIndex,   // 索引
        LPTSTR lpName,   // 子键的名称
        LPDWORD lpcbName,  // 子键名称的长度
        LPDWORD lpReserved, // 保留
        LPTSTR lpClass,   // address of buffer for class string
        LPDWORD lpcbClass, // address for size of class buffer
        PFILETIME lpftLastWriteTime  // address for time key last 
written to
      );

RegEnumKey()与上类似
 
LONG RegQueryInfoKey(
        HKEY hKey,        // 已打开的键的句柄
        LPTSTR lpClass,      // 类型名称,仅使用于NT。若不使用则传入Null
        LPDWORD lpcbClass,    // 类型名称的长度
        LPDWORD lpReserved,    // 保留
        LPDWORD lpcSubKeys,    // 返回子键的数目              
        LPDWORD lpcbMaxSubKeyLen, // 返回最长的子键长度              
        LPDWORD lpcbMaxClassLen, // 返回最长的类长度 
        LPDWORD lpcValues,    // 返回值的数目              
        LPDWORD lpcbMaxValueNameLen, // 返回最长的值项名称的长度
        LPDWORD lpcbMaxValueLen, // 返回最长的值的长度
        LPDWORD lpcbSecurityDescriptor, //返回安全描述,仅适用于 NT
        PFILETIME lpftLastWriteTime  // 返回键最后被写入的时间,仅适用于 NT
     );
 
 其他:
 
LONG RegLoadKey(
        HKEY hKey,    // 打开的句柄
        LPCTSTR lpSubKey, //子键的路径          
        LPCTSTR lpFile  // 要写入注册表信息的文件
      );
 
LONG RegReplaceKey(
        HKEY hKey,     // handle to open key
        LPCTSTR lpSubKey, // address of name of subkey
        LPCTSTR lpNewFile, // 在替换前生成新的备份文件
        LPCTSTR lpOldFile // 需要覆盖上注册表的文件
      );
 
LONG RegSaveKey(
     HKEY hKey,    // 要保存的句柄
     LPCTSTR lpFile, // 保存子键的文件
     LPSECURITY_ATTRIBUTES lpSecurityAttributes    //不太懂(大概是与安全有关的属性设置)      
    );
 

LONG RegConnectRegistry(
        LPTSTR lpMachineName, //远程计算机的名称
        HKEY hKey,    // 预先注册的句柄
        PHKEY phkResult  // 远程计算机上的句柄
     );

LONG RegUnLoadKey(
     HKEY hKey,     // handle to open key
     LPCTSTR lpSubKey  // address of name of subkey to unload
    );

LONG RegNotifyChangeKeyValue(
      HKEY hKey, // 要监视的一个项的句柄
      BOOL bWatchSubtree, // 是否监视此项的子键
      DWORD dwNotifyFilter, // 监视哪些变化
      HANDLE hEvent, // 接受注册表变化事件的事件对象句柄
      BOOL fAsynchronous    // 注册表变化前报告还是注册表变化后才报告  
     );

LONG RegRestoreKey(
  HKEY hKey,      // handle to key where restore   begins
  LPCTSTR lpFile, // registry file
  DWORD dwFlags   // options
);

LONG RegSetKeySecurity( HKEY hKey,                              // handle to key
  SECURITY_INFORMATION SecurityInformation // request
  PSECURITY_DESCRIPTOR pSecurityDescriptor // SD
);

LONG RegGetKeySecurity(
  HKEY hKey,                                // handle to key
  SECURITY_INFORMATION SecurityInformation, // request
  PSECURITY_DESCRIPTOR pSecurityDescriptor, // SD
  LPDWORD lpcbSecurityDescriptor           // buffer size
);

原文地址:https://www.cnblogs.com/FindSelf/p/3723698.html