SDK 注册表 读写
2009-09-13 20:52
162 查看
#include <iostream> #include <string> #include <cctype> #include <windows.h> using namespace std; void RegWrite(); void RegRead(); int main() { RegWrite(); RegRead(); return 0; } void RegWrite() { HKEY hKEY; //The RegCreateKey function creates the specified registry key. If the key already exists in the registry, the function opens it. RegCreateKey(HKEY_LOCAL_MACHINE,"Software//Mike//admin",&hKEY); //The RegSetValue function sets the data for the default or unnamed value of a specified registry key. The data must be a text string. //设置默认的KEY的value RegSetValue(hKEY,NULL,REG_SZ,"Mike",strlen("Mike")); DWORD dwAge=89; //The RegSetValueEx function sets the data and type of a specified value under a registry key. RegSetValueEx(hKEY,"age",0,REG_DWORD,(CONST BYTE*)&dwAge,4); RegCloseKey(hKEY); } void RegRead() { //方法一 读取一般的 key 的值 LONG lValue; //lValue 用于存储值的字节产度 RegQueryValue(HKEY_LOCAL_MACHINE,"Software//Mike//admin",NULL,&lValue); char* pBuf=new char[lValue]; RegQueryValue(HKEY_LOCAL_MACHINE,"Software//Mike//admin",pBuf,&lValue); cout<<pBuf<<endl; //方法二 HKEY hKey; RegOpenKey(HKEY_LOCAL_MACHINE,"Software//Mike//admin",&hKey); DWORD dwType; DWORD dwValue; DWORD dwAge; RegQueryValueEx(hKey,"age",0,&dwType,(LPBYTE)&dwAge,&dwValue); cout<<dwAge<<endl; }
效果:
相关文章推荐
- 一个简单的读写注册表实例
- 读写注册表的自定义函数
- 【VS调试】C#读写Windows 7注册表时抛出“不允许所请求的注册表访问权”的解决办法
- C#读写注册表
- C#读写注册表
- ConfigurationPattern V1.1.1 版本发布--该版本增加自动读写注册表配置的功能
- java读写注册表的两种方式,Preferences与jRegistry
- WinCE下读写注册表的又一种方法
- Win32 SDK注册表操作——RegCloseKey
- VB中如何实现注册表的读写
- 如何在Windows服务程序中读写HKEY_CURRENT_USER注册表
- window服务 无法读写注册表
- 注册表 读写练习
- 读写sdk文件
- javascript ActiveXObject javascript取得机器名,用户名,读写注册表,启动应用程序
- 读写注册表
- 读写注册表
- .net读写注册表
- 读写注册表
- 注册表的读写问题