Esempio n. 1
0
	HRESULT GetComCtl32Version(DLLVERSIONINFO2 & p_dvi, pfc::string_base * p_path_out)
	{
		static bool have_version = false;
		static HRESULT rv = E_FAIL;

		static DLLVERSIONINFO2 g_dvi;

		if (!have_version || p_path_out)
		{
			HINSTANCE hinstDll = LoadLibrary(_T("comctl32.dll"));

			if (hinstDll)
			{
				if (p_path_out)
					uGetModuleFileName(hinstDll, *p_path_out);

				if (!have_version)
				{
					DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll, "DllGetVersion");

					if (pDllGetVersion)
					{

						memset(&g_dvi, 0, sizeof(DLLVERSIONINFO2));
						g_dvi.info1.cbSize = sizeof(DLLVERSIONINFO2);

						rv = (*pDllGetVersion)(&g_dvi.info1);

						if (FAILED(rv))
						{
							memset(&g_dvi, 0, sizeof(DLLVERSIONINFO));
							g_dvi.info1.cbSize = sizeof(DLLVERSIONINFO);

							rv = (*pDllGetVersion)(&g_dvi.info1);
						}
					}
					have_version = true;
				}
				FreeLibrary(hinstDll);
			}
		}
		p_dvi = g_dvi;
		return rv;
	}
Esempio n. 2
0
void toolbar_extension::button::custom_image::get_path(pfc::string8 & p_out) const
{
	p_out.reset();

	bool b_absolute = pfc::string_find_first(m_path, ':') != pfc_infinite || (m_path.length() > 1 && m_path.get_ptr()[0] == '\\' && m_path.get_ptr()[1] == '\\');
	bool b_relative_to_drive = !b_absolute && m_path.get_ptr()[0] == '\\';

	pfc::string8 fb2kexe;
	uGetModuleFileName(NULL, fb2kexe);
	//pfc::string8 fullPath;

	if (b_relative_to_drive)
	{
		t_size index_colon = fb2kexe.find_first(':');
		if (index_colon != pfc_infinite)
			p_out.add_string(fb2kexe.get_ptr(), index_colon + 1);
	}
	else if (!b_absolute)
		p_out << pfc::string_directory(fb2kexe) << "\\";
	p_out += m_path;
}