MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / GetProgramFilesDir

Function GetProgramFilesDir

src/yvalve/gds.cpp:4226–4258  ·  view source on GitHub ↗

We try to see if the registry has the information for the Program Files directory, that follows the boot partition and is localized.

Source from the content-addressed store, hash-verified

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.
4226static 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

Callers 1

initMethod · 0.85

Calls 3

recalculate_lengthMethod · 0.80
reserveMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected