您的位置:首页 > 其它

wince 注册表操作。

2013-09-06 11:31 471 查看
原创:http://blog.sina.com.cn/u/2312748742

 

BOOL UpdataDataToReg(LPCTSTR lpSubKey,LPCTSTR lpValueName,TCHAR*
lpData,DWORD dwSize)

{

 HKEY hKey;

 bool breturn=false;

 if(ERROR_SUCCESS !=
RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpSubKey, 0, 0,
&hKey))

 {

  DWORD dwDisposition = 0;

  RegCreateKeyEx(HKEY_LOCAL_MACHINE,
lpSubKey,

   0, NULL,
REG_OPTION_NON_VOLATILE, 0, NULL, &hKey,
&dwDisposition);

 } 

 if(ERROR_SUCCESS ==
RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpSubKey, 0, 0,
&hKey))

 {

  RegSetValueEx(hKey,
lpValueName, 0, REG_SZ,(LPBYTE)lpData,
dwSize); 

  breturn=TRUE;   

  RegCloseKey(hKey);

 }

 return breturn;

}

BOOL GetDataFromReg(LPCTSTR lpSubKey,LPCTSTR lpValueName,TCHAR*
lpDataReturn,DWORD dwSize)

{

 HKEY hKey;

 bool breturn=false;

 if(ERROR_SUCCESS ==
RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpSubKey, 0, 0,
&hKey))

 {

  if
(ERROR_SUCCESS==RegQueryValueEx(hKey, lpValueName, NULL,
NULL,(LPBYTE)lpDataReturn, &dwSize))

  {   

   breturn=true; 

  }

  RegCloseKey(hKey);

 }

 return breturn;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: