win32 注册表操作
创建键 RegCreateKeyEx
int SetRecordVideoSavedDays(int newSavedDays)
{
HKEY hSubKey = NULL;
LONG lRet = ;
DWORD dwType = ;
int iRet = ; do
{
if (newSavedDays < )
{
printf("error: input negative number\n");
break;
}
lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Cloudsoar 3C\\ServerInfo",
, NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL, &hSubKey, NULL);
if (ERROR_SUCCESS != lRet)
{
printf("Create Reg failed\n");
break;
} lRet = RegSetValueEx(hSubKey, "VideoSavedDays", , REG_DWORD, (BYTE*)&newSavedDays, sizeof(newSavedDays));
if (ERROR_SUCCESS != lRet)
{
printf("Set reg value VideoSavedDays failed\n");
break;
} iRet = (int)newSavedDays;
} while (); if(NULL != hSubKey)
{
RegCloseKey(hSubKey);
hSubKey = NULL;
} return iRet;
} // parameter1: out, save video saved path
// parameter2: in, save path length
BOOL GetRecordVideoSavedPath(char *pchPath,int pathBufLen)
{
HKEY hSubKey = NULL;
LONG lRet = ;
DWORD dwType = ;
DWORD dwPathLen = pathBufLen;
BOOL bRet = FALSE; do
{
lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Cloudsoar 3C\\ServerInfo",
, KEY_READ, &hSubKey);
if (ERROR_SUCCESS != lRet)
{
printf("Open reg value VideoSavedPath failed\n");
break;
} lRet = RegQueryValueEx(hSubKey, "VideoSavedPath",
, &dwType, (LPBYTE)pchPath, &dwPathLen);
if (ERROR_SUCCESS != lRet)
{
printf("Query reg value VideoSavedPath failed\n");
break;
} bRet = TRUE; } while (); RegCloseKey(hSubKey); return bRet;
} BOOL SetRecordVideoSavePath(char *pchNewPath)
{
HKEY hSubKey = NULL;
LONG lRet = ;
DWORD dwType = ;
DWORD dwState = ;
BOOL bRet = FALSE; do
{
if (NULL == pchNewPath)
{
printf("error: input negative new path\n");
break;
}
lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Cloudsoar 3C\\ServerInfo",
, NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL, &hSubKey, &dwState);
if (ERROR_SUCCESS != lRet)
{
printf("Create Reg VideoSavedPath failed\n");
break;
} lRet = RegSetValueEx(hSubKey, "VideoSavedPath", , REG_SZ, (PBYTE)pchNewPath, sizeof(pchNewPath));
if (ERROR_SUCCESS != lRet)
{
printf("Set reg value VideoSavedPath failed\n");
break;
} bRet = TRUE;
} while (); RegCloseKey(hSubKey); return bRet;
}
函数原型
LONG RegCreateKeyEx(
HKEY hKey, // handle to open key
LPCTSTR lpSubKey, // subkey name
DWORD Reserved, // reserved
LPTSTR lpClass, // class string
DWORD dwOptions, // special options
REGSAM samDesired, // desired security access
LPSECURITY_ATTRIBUTES lpSecurityAttributes, // inheritance
PHKEY phkResult, // key handle
LPDWORD lpdwDisposition // disposition value buffer
);
参数说明
hKey: 要打开键的句柄或以下预定义句柄
HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
lpSubKey: 指向一个用于定义子键路径的字符串
Reserved,dwOptions,samDesired: 置0
lpClass,lpSecurityAttributes: 置NULL
phkResult: 用于接收键句柄
lpdwDisposition: 接收的相关信息,取值如下
REG_CREATED_NEW_KEY 创建成功
REG_OPENED_EXISTING_KEY 键已存在
打开键 RegOpenKeyEx
函数原型
LONG RegOpenKeyEx(
HKEY hKey, // handle to open key
LPCTSTR lpSubKey, // subkey name
DWORD ulOptions, // reserved
REGSAM samDesired, // security access mask
PHKEY phkResult // handle to open key
);
参数说明
hKey: 要打开键的句柄或以下预定义句柄
HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
lpSubKey: 指向一个用于定义子键路径的字符串
ulOptions: 保留位,置0
samDesired: 打开键后键的操作权限
phResult: 接收打开的键的句柄
修改/添加键值 RegSetValueEx
函数原型
LONG RegSetValueEx(
HKEY hKey, // handle to key
LPCTSTR lpValueName, // value name
DWORD Reserved, // reserved
DWORD dwType, // value type
CONST BYTE *lpData, // value data
DWORD cbData // size of value data
);
参数说明
hKey: 打开键的句柄或以下预定义句柄
HKEY_CLASSES_ROOT
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
lpValueName: 键值的名称
Reserved: 保留位,置0
dwType: 键值的类型
lpData: 键值
cbData: 键值数据长度
win32 注册表操作的更多相关文章
- 注册表操作 Microsoft.Win32.Registry与RegistryKey类
一.注册表操作简介 Registry 类,RegistryKey 类提供了操作注册表的接口 RegistryValueKind:用于指定操作注册表的数据类型 一.注册表巢 在注册表中,最上面的节点是注 ...
- delphi 注册表操作(读取、添加、删除、修改)完全手册
DELPHI VS PASCAL(87) 32位Delphi程序中可利用TRegistry对象来存取注册表文件中的信息. 一.创建和释放TRegistry对象 1.创建TRegistry对象.为了操 ...
- CRegKey 注册表操作
CRegKey 注册表操作 标签: accessnulluserpathbyteie 2011-11-03 13:55 3477人阅读 评论(0) 收藏 举报 分类: win32(7) 1.简介 ...
- C# 我的注册表操作类
using System; using System.Collections.Generic; using System.Text; using Microsoft.Win32; using Syst ...
- Delphi的注册表操作
转帖:Delphi的注册表操作 2009-12-21 11:12:52 分类: Delphi的注册表操作 32位Delphi程序中可利用TRegistry对象来存取注册表文件中的信息. 一.创 ...
- C#注册表操作类--完整优化版
using System; using System.Collections.Generic; using System.Text; using Microsoft.Win32; namespace ...
- C#注册表操作类(完整版) 整理完整
/// <summary> /// 注册表基项静态域 /// /// 主要包括: /// 1.Registry.ClassesRoot 对应于HKEY_CLASSES_ROOT主键 /// ...
- 【读书笔记】C#高级编程 第二十四章 文件和注册表操作
(一)文件和注册表 对于文件系统操作,相关的类几乎都在System.IO名称空间中,而注册表操作由System.Win32名称空间中的类来处理. (二)管理文件系统 System.MarshalByR ...
- MFC学习 文件操作注册表操作
c读写文件 void CFileView::OnRead() { FILE *pFile = fopen("1.txt", "r"); /*char ch[10 ...
随机推荐
- 制作u盘kali系统启动盘
准备好一个容量大于8G的u盘,和kali系统的镜像文件. 下载universal-usb-install软件,打开设置如下,create等待几分钟. 下载minitool分区工具,插入u盘,打开min ...
- STOP OUR NEGATIVE THOUGHTS
Do you ever feel like you're in over your head and at any moment you're going to burst? You're not a ...
- 一、Iterator 迭代器
需求:如何不适用for循环,依次遍历出数组中每个元素? 设计原理: 代码清单: 接口类 public interface Iterator { boolean hasNext(); Object ne ...
- Android笔记:ContextMenu
ContextMenu,称为上下文菜单,也就是长按界面不放,弹出的菜单.使用ContextMenu有三个步骤: (1)调用registerForContextMenu()方法,为视图注册上下文菜单: ...
- nginx 刷新显示404
HTML5 History 模式 vue-router 默认 hash 模式 —— 使用 URL 的 hash 来模拟一个完整的 URL,于是当 URL 改变时,页面不会重新加载. 如果不想要很丑的 ...
- 从上往下打印二叉树(python)
题目描述 从上往下打印出二叉树的每个节点,同层节点从左至右打印. # -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # ...
- Tensorflow函数——tf.variable_scope()
Tensorflow函数——tf.variable_scope()详解 https://blog.csdn.net/yuan0061/article/details/80576703 2018年06月 ...
- http://www.bugku.com:Bugku——Easy_vb
之前复习了汇编等知识,这是人生中第一个逆向题目,嘻嘻. 启程. 对于执行文件,首先需要看它是32位还是64位的.这里了解到静态工具IDA的启动程序为idaq.exe和idaq64.exe( ...
- 微信小程序编译包的获取与解压——在手机中获取小程序编译包wxapkg
准备工作: 微信关注需要下载编译包的小程序,然后点进去看一下,微信就会自动下载相应的编译包到手机上了. 获取小程序编译包: 据说root手机可以直接在手机的文件管理中查找wxapkg文件,自己尝试了下 ...
- FortiGate常用命令
1.命令结构 config Configure object. 对策略,对象等进行配置 get Get dynamic and system information. 查看相关关对 ...