Esempio n. 1
0
void CExceptionHandler::Register()
{
// (( scope ))
{
	ASSERT(g_lpExceptionHandler == NULL);

	// Build our required extra information.

	g_szExtraInformation = GetVersionInformation();

	if (g_szExtraInformation == NULL)
	{
		goto __failed;
	}

	// Find the path to create the dump files in and ensure it exists.

	wstring szCrashDumpPath(GetDirname(GetModuleFileNameEx()) + L"\\" + CRASH_DUMP_PATH);

	SetEnvironmentVariable(L"MOZ_CRASHREPORTER_DATA_DIRECTORY", szCrashDumpPath.c_str());

	DWORD dwAttr = GetFileAttributes(szCrashDumpPath.c_str());

	if (dwAttr == INVALID_FILE_ATTRIBUTES)
	{
		BOOL fResult = CreateDirectory(szCrashDumpPath.c_str(), NULL);

		if (!fResult)
		{
			goto __failed;
		}
	}

	// Set the module name as the first restart parameter so the crash
	// reporter displays the restart button.

	SetEnvironmentVariable(L"MOZ_CRASHREPORTER_RESTART_ARG_0", GetModuleFileNameEx().c_str());

	// Create the exception handler.

	g_lpExceptionHandler = new google_breakpad::ExceptionHandler(
		GetDirname(GetModuleFileNameEx()).c_str(),
		NULL,
		MinidumpCallback,
		NULL,
		google_breakpad::ExceptionHandler::HANDLER_ALL
	);

	return;
}

__failed:
	if (g_szExtraInformation != NULL)
	{
		free(g_szExtraInformation);

		g_szExtraInformation = NULL;
	}
}
Esempio n. 2
0
void SetTimidityEnvPath(const Settings & conf)
{
    const std::string prefix_timidity = std::string("files") + SEPARATOR + std::string("timidity");
    const std::string result = Settings::GetLastFile(prefix_timidity, "timidity.cfg");

    if(IsFile(result))
	setenv("TIMIDITY_PATH", GetDirname(result).c_str(), 1);
}
Esempio n. 3
0
void CNotifierApp::CreateShortcut()
{
	HRESULT hr;
	IShellLink * lpShellLink = NULL;
	IPersistFile * lpPersistFile = NULL;
	WCHAR szStartupPath[MAX_PATH];
	wstring szModuleFilename(GetModuleFileNameEx());
	wstring szModulePath(GetDirname(szModuleFilename));

	if (!SHGetSpecialFolderPath(NULL, szStartupPath, CSIDL_STARTUP , FALSE))
	{
		return;
	}

	wstring szTargetPath(szStartupPath);

	szTargetPath += L"\\Google Wave Notifier.lnk";

	hr = CoCreateInstance(
		CLSID_ShellLink,
		NULL,
		CLSCTX_INPROC_SERVER,
		IID_IShellLink,
		reinterpret_cast<void**>(&lpShellLink)
	);

	if (!SUCCEEDED(hr))
	{
		goto __end;
	}

	ASSERT(lpShellLink != NULL);

	lpShellLink->SetIconLocation(szModuleFilename.c_str(), 0);
	lpShellLink->SetPath(szModuleFilename.c_str());
	lpShellLink->SetWorkingDirectory(szModulePath.c_str());

	hr = lpShellLink->QueryInterface(
		IID_IPersistFile,
		reinterpret_cast<void**>(&lpPersistFile)
	);

	if (!SUCCEEDED(hr))
	{
		goto __end;
	}

	ASSERT(lpPersistFile != NULL);

	// hr not checked because we can't do anything about it.

	lpPersistFile->Save(szTargetPath.c_str(), FALSE);

__end:
	if (lpPersistFile != NULL)
	{
		lpPersistFile->Release();
	}

	if (lpShellLink != NULL)
	{
		lpShellLink->Release();
	}
}