| | 219 | } |
| | 220 | |
| | 221 | // forward declaration |
| | 222 | char* ConvertFromWideString(const WCHAR* pString, unsigned int codepage); |
| | 223 | |
| | 224 | // -------------------------------------------------------------------------- |
| | 225 | // |
| | 226 | // Function |
| | 227 | // Name: GetDefaultConfigFilePath(std::string name) |
| | 228 | // Purpose: Calculates the default configuration file name, |
| | 229 | // by using the directory location of the currently |
| | 230 | // executing program, and appending the provided name. |
| | 231 | // In case of fire, returns an empty string. |
| | 232 | // Created: 26th May 2007 |
| | 233 | // |
| | 234 | // -------------------------------------------------------------------------- |
| | 235 | std::string GetDefaultConfigFilePath(const std::string& rName) |
| | 236 | { |
| | 237 | WCHAR exePathWide[MAX_PATH]; |
| | 238 | GetModuleFileNameW(NULL, exePathWide, MAX_PATH-1); |
| | 239 | |
| | 240 | char* exePathUtf8 = ConvertFromWideString(exePathWide, CP_UTF8); |
| | 241 | if (exePathUtf8 == NULL) |
| | 242 | { |
| | 243 | return ""; |
| | 244 | } |
| | 245 | |
| | 246 | std::string configfile = exePathUtf8; |
| | 247 | delete [] exePathUtf8; |
| | 248 | |
| | 249 | // make the default config file name, |
| | 250 | // based on the program path |
| | 251 | configfile = configfile.substr(0, |
| | 252 | configfile.rfind('\\')); |
| | 253 | configfile += "\\"; |
| | 254 | configfile += rName; |
| | 255 | |
| | 256 | return configfile; |
| 1280 | | if (RegSetValueEx(hk, // subkey handle |
| 1281 | | "EventMessageFile", // value name |
| 1282 | | 0, // must be zero |
| 1283 | | REG_EXPAND_SZ, // value type |
| 1284 | | (LPBYTE) exepath.c_str(), // pointer to value data |
| 1285 | | (DWORD) (exepath.size()))) // data size |
| | 1318 | if (RegSetValueExW(hk, // subkey handle |
| | 1319 | L"EventMessageFile", // value name |
| | 1320 | 0, // must be zero |
| | 1321 | REG_EXPAND_SZ, // value type |
| | 1322 | (LPBYTE)cmd, // pointer to value data |
| | 1323 | len*sizeof(WCHAR))) // data size |
| 1313 | | if (RegSetValueEx(hk, // subkey handle |
| 1314 | | "CategoryMessageFile", // value name |
| 1315 | | 0, // must be zero |
| 1316 | | REG_EXPAND_SZ, // value type |
| 1317 | | (LPBYTE) exepath.c_str(), // pointer to value data |
| 1318 | | (DWORD) (exepath.size()))) // data size |
| | 1351 | if (RegSetValueExW(hk, // subkey handle |
| | 1352 | L"CategoryMessageFile", // value name |
| | 1353 | 0, // must be zero |
| | 1354 | REG_EXPAND_SZ, // value type |
| | 1355 | (LPBYTE)cmd, // pointer to value data |
| | 1356 | len*sizeof(WCHAR))) // data size |