1 char* read_reg_sz()//读取操作表,其类型为REG_SZ
2 {
3 HKEY hkey;
4 LPCTSTR data_set = _T("\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"); //\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Favorites"'
5
6 if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_CURRENT_USER, data_set, 0, KEY_READ, &hkey))
7 {
8 TCHAR dwValue[256];
9 DWORD dwSzType = REG_SZ;
10 DWORD dwSize = sizeof(dwValue);
11 _tsetlocale(LC_ALL, _T("chs"));
12 if (::RegQueryValueEx(hkey, _T("Favorites"), 0, &dwSzType, (LPBYTE)&dwValue, &dwSize) != ERROR_SUCCESS)
13 {
14 cout << "无法查询有关的注册表信息" << endl;
15 }
16 char* reValue;
17 reValue = UnicodeToAnsi(dwValue);
18 ::RegCloseKey(hkey);
19 return reValue;
20 }
21 ::RegCloseKey(hkey);
22 }