创建键 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:   键值数据长度

最新文章

  1. JSON方式提交文档时SOLR报:AtomicUpdateDocumentMerger Unknown operation for the an atomic update, operation ignored
  2. MVC使用x.PagedList分页
  3. input输入内容时放大问题
  4. CSS折行小记
  5. css 网站变灰色
  6. Centos7 创建个文件 thread 怪现象
  7. 通过python切换hosts文件
  8. 2014年3月份第2周51Aspx源码发布详情
  9. linux上nagios安装完整版
  10. magento1.x 运行在 php7 优惠券的问题
  11. WiFi天线分集
  12. Android Studio 受不了了
  13. Storm入门(十四)Trident API Overview
  14. 基于OpenCv和swing的图片/视频展示Java实现
  15. Spring中JdbcTemplate使用RowMapper
  16. Unity 3D编辑器扩展介绍、教程(二) —— 创建窗口
  17. 利用IPC通道进行进程间通信(C#)
  18. Google Analytics10条有用教程(转)
  19. 2016-2017 CT S03E07: Codeforces Trainings Season 3 Episode 7
  20. Attribute基本介绍

热门文章

  1. GreaseMonkey开发(一):第一个自定义插件Hello GreaseMonkey!
  2. Pandas基本功能之算术运算、排序和排名
  3. Windows配置Java环境
  4. 数值的整数次方(python)
  5. 51nod 1459 迷宫游戏 dijkstra模板
  6. FZU-1752.(A^B mod C)(快速幂与快速乘优化)
  7. Django import相关
  8. web接口的开发
  9. jq里面关于disable的用法
  10. mysqldump 导出数据库各参数详细说明