static OrderedTask * task_load(const TaskBehaviour &task_behaviour) { PathName szFilename(task_file.c_str()); auto *task = LoadTask(szFilename, task_behaviour); if (task != nullptr) { task->UpdateStatsGeometry(); if (!task->CheckTask()) { delete task; return nullptr; } } return task; }
static OrderedTask* task_load(OrderedTask* task) { PathName szFilename(task_file.c_str()); DataNode *root = DataNodeXML::Load(szFilename); if (!root) return NULL; Deserialiser des(*root); des.Deserialise(*task); if (task->CheckTask()) { delete root; return task; } delete task; delete root; return NULL; }
void CNotifierApp::DetectStartWithWindowsSetting() { m_szShortcutTargetPath = L""; WCHAR szPath[MAX_PATH]; wstring szModulePath(GetLongPathName(GetModuleFileNameEx())); if (!SHGetSpecialFolderPath(NULL, szPath, CSIDL_STARTUP , FALSE)) { return; } wstring szFindPath(szPath); szFindPath += L"\\*.lnk"; WIN32_FIND_DATA wfd; HANDLE hFind = FindFirstFile(szFindPath.c_str(), &wfd); if (hFind != INVALID_HANDLE_VALUE) { do { if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { continue; } wstring szFilename(szPath); szFilename += L"\\"; szFilename += wfd.cFileName; if (DetectShortcut(szModulePath, szFilename)) { m_szShortcutTargetPath = szFilename; break; } } while (FindNextFile(hFind, &wfd) != 0); } FindClose(hFind); CSettings(TRUE).SetStartWithWindows(!m_szShortcutTargetPath.empty()); }
LPSTR CExceptionHandler::GetVersionInformation() { LPSTR szResult = NULL; LPVOID lpData = NULL; // (( scope )) { stringstream szDetails; // Load the version information. wstring szFilename(GetModuleFileNameEx()); DWORD dwHandle = 0; DWORD dwSize = GetFileVersionInfoSize(szFilename.c_str(), &dwHandle); if (dwSize == 0) { goto __end; } lpData = malloc(dwSize); if (!GetFileVersionInfo(szFilename.c_str(), dwHandle, dwSize, lpData)) { goto __end; } // Get the product name. UINT uLen; LPCWSTR szData; if (!VerQueryValue(lpData, L"\\StringFileInfo\\040904b0\\ProductName", (LPVOID*)&szData, &uLen)) { goto __end; } szDetails << "ProductName=" << ConvertToMultiByte(szData) << "\n"; // Get the vendor. if (!VerQueryValue(lpData, L"\\StringFileInfo\\040904b0\\CompanyName", (LPVOID*)&szData, &uLen)) { goto __end; } szDetails << "Vendor=" << ConvertToMultiByte(szData) << "\n"; // Get the application version. VS_FIXEDFILEINFO * lpffi; if (!VerQueryValue(lpData, L"\\", (LPVOID *)&lpffi, &uLen)) { goto __end; } ASSERT(lpffi != NULL); wstring szVersion(Format( L"%d.%d.%d.%d", (INT)HIWORD(lpffi->dwProductVersionMS), (INT)LOWORD(lpffi->dwProductVersionMS), (INT)HIWORD(lpffi->dwProductVersionLS), (INT)LOWORD(lpffi->dwProductVersionLS))); szDetails << "Version=" << ConvertToMultiByte(szVersion) << "\n"; // Build the server URL. szDetails << "ServerURL=" << ConvertToMultiByte(CRASH_SERVER_URL) << "\n"; wstring szCookie; if (CSettings(FALSE).GetStatisticsCookie(szCookie)) { szDetails << "Cookie=" << ConvertToMultiByte(szCookie) << "\n"; } szResult = _strdup(szDetails.str().c_str()); } __end: if (lpData != NULL) { free(lpData); } return szResult; }