We try to see if the registry has the information for the Program Files directory, that follows the boot partition and is localized.
| 4224 | // We try to see if the registry has the information for the Program Files |
| 4225 | // directory, that follows the boot partition and is localized. |
| 4226 | static bool GetProgramFilesDir(Firebird::PathName& output) |
| 4227 | { |
| 4228 | #ifdef WIN_NT |
| 4229 | const char* pdir = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion"; |
| 4230 | const char* pvalue = "ProgramFilesDir"; |
| 4231 | |
| 4232 | HKEY hkey; |
| 4233 | LONG rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, pdir, 0, KEY_READ, &hkey); |
| 4234 | if (rc != ERROR_SUCCESS) |
| 4235 | return false; |
| 4236 | |
| 4237 | DWORD type, size = 0; |
| 4238 | rc = RegQueryValueEx(hkey, pvalue, NULL, &type, NULL, &size); |
| 4239 | if (rc != ERROR_SUCCESS || type != REG_SZ || !size) |
| 4240 | { |
| 4241 | RegCloseKey(hkey); |
| 4242 | return false; |
| 4243 | } |
| 4244 | |
| 4245 | output.reserve(size); |
| 4246 | BYTE* answer = reinterpret_cast<BYTE*>(output.begin()); |
| 4247 | rc = RegQueryValueEx(hkey, pvalue, NULL, &type, answer, &size); |
| 4248 | RegCloseKey(hkey); |
| 4249 | if (rc != ERROR_SUCCESS) |
| 4250 | return false; |
| 4251 | |
| 4252 | output.recalculate_length(); |
| 4253 | output += "\\Firebird\\"; |
| 4254 | return true; |
| 4255 | #else |
| 4256 | return false; |
| 4257 | #endif |
| 4258 | } |
| 4259 | |
| 4260 | |
| 4261 | // Deprecated private API functions |
no test coverage detected