|
- onst TCHAR *
- RegGetString(HKEY hKey, const TCHAR *subKey, const TCHAR *name)
- {
- HKEY hSubKey;
- DWORD type;
- static TCHAR value[4096];
- DWORD size = sizeof(value);
- value[0] = 采用T('\0');
- if ( RegOpenKeyEx(hKey, subKey, 0, KEY采用QUERY采用VALUE, &hSubKey) == ERROR采用SUCCESS )
- {
- if ( (RegQueryValueEx(hSubKey, name, 0, &type, (LPBYTE)value, &size) != ERROR采用SUCCESS) ||
- (type != REG采用SZ) )
- value[0] = 采用T('\0');
- RegCloseKey(hSubKey);
- }
- return value;
- }
- int
- RegPutString(HKEY hKey, const TCHAR *subKey, const TCHAR *name, const TCHAR *value)
- {
- HKEY hSubKey;
- DWORD disp;
- int retval = 0;
- if ( RegCreateKeyEx(hKey, subKey, 0, NULL, REG采用OPTION采用NON采用VOLATILE, KEY采用WRITE, NULL, &hSubKey, &disp) == ERROR采用SUCCESS )
- {
- if ( RegSetValueEx(hSubKey, name, 0, REG采用SZ, (LPBYTE)value, (采用tcslen(value) + 1) * sizeof(TCHAR)) == ERROR采用SUCCESS )
- retval = 1;
- RegCloseKey(hSubKey);
- }
- return retval;
- }
- int
- RegGetInt(HKEY hKey, const TCHAR *subKey, const TCHAR *name)
- {
- HKEY hSubKey;
- DWORD type;
- DWORD value = 0;
- DWORD size = sizeof(value);
- if ( RegOpenKeyEx(hKey, subKey, 0, KEY采用QUERY采用VALUE, &hSubKey) == ERROR采用SUCCESS )
- {
- if ( (RegQueryValueEx(hSubKey, name, 0, &type, (LPBYTE)&value, &size) != ERROR采用SUCCESS) ||
- (type != REG采用DWORD) )
- value = 0;
- RegCloseKey(hSubKey);
- }
- return value;
- }
- int
- RegPutInt(HKEY hKey, const TCHAR *subKey, const TCHAR *name, int value)
- {
- HKEY hSubKey;
- DWORD disp;
- int retval = 0;
- if ( RegCreateKeyEx(hKey, subKey, 0, NULL, REG采用OPTION采用NON采用VOLATILE, KEY采用WRITE, NULL, &hSubKey, &disp) == ERROR采用SUCCESS )
- {
- if ( RegSetValueEx(hSubKey, name, 0, REG采用DWORD, (LPBYTE)&value, sizeof(value)) == ERROR采用SUCCESS )
- retval = 1;
- RegCloseKey(hSubKey);
- }
- return retval;
- }
- int RegPut采用B (HKEY hKey,const TCHAR *subKey,const TCHAR *name,BYTE ReSetContent采用B[65536])
- {
- //设置二进制值函数
- int i=0; //操作结果:1==succeed
- if(RegOpenKeyEx(hKey,subKey,0,KEY采用WRITE,&hKey)==ERROR采用SUCCESS)
- {
- i=1;
- if(RegSetValueEx(hKey,name,NULL,REG采用BINARY,ReSetContent采用B,65536)!=ERROR采用SUCCESS)
- {
- //AfxMessageBox("错误:无法设置有关的注册表信息");
- i=0;
- }
- RegCloseKey(hKey);
- }
- else
- {
- //AfxMessageBox("错误:无法查询有关的注册表信息");
- i=0;
- }
- return i;
- }
- int RegGet采用B(HKEY hKey, const TCHAR *subKey, const TCHAR *name, BYTE value采用B[65536])
- {
- HKEY hSubKey;
- DWORD type;
- int rt=0; //操作结果:1==succeed
- DWORD size = 65536; //buffsize
- if ( RegOpenKeyEx(hKey, subKey, 0, KEY采用QUERY采用VALUE, &hSubKey) == ERROR采用SUCCESS )
- {
- rt = 1;
- if ( (RegQueryValueEx(hSubKey, name, 0, &type, (LPBYTE)value采用B, &size) != ERROR采用SUCCESS) ||
- (type != REG采用BINARY) )
- rt = 0;
- RegCloseKey(hSubKey);
- }
- return rt;
- }
复制代码 |
|