void CAboutDlg::OnCopyToClipboard() { CStringW info = m_appname + _T("\r\n"); info += CString(_T('-'), m_appname.GetLength()) + _T("\r\n\r\n"); info += _T("Build information:\r\n"); info += _T(" Version: ") + m_strBuildNumber + _T("\r\n"); info += _T(" Compiler: ") + m_MPCCompiler + _T("\r\n"); info += _T(" Build date: ") + m_buildDate + _T("\r\n\r\n"); #ifndef MPCHC_LITE info += _T("LAV Filters:\r\n"); info += _T(" LAV Splitter: ") + CFGFilterLAV::GetVersion(CFGFilterLAV::SPLITTER) + _T("\r\n"); info += _T(" LAV Video: ") + CFGFilterLAV::GetVersion(CFGFilterLAV::VIDEO_DECODER) + _T("\r\n"); info += _T(" LAV Audio: ") + CFGFilterLAV::GetVersion(CFGFilterLAV::AUDIO_DECODER) + _T("\r\n"); info += _T(" FFmpeg compiler: ") + CString(g_Gcc_Compiler) + _T("\r\n\r\n"); #endif info += _T("Operating system:\r\n"); info += _T(" Name: ") + m_OSName + _T("\r\n"); info += _T(" Version: ") + m_OSVersion + _T("\r\n"); if (CComPtr<IDirect3D9> pD3D9 = Direct3DCreate9(D3D_SDK_VERSION)) { info += _T("\r\nVideo device(s):\r\n"); for (UINT adapter = 0, adapterCount = pD3D9->GetAdapterCount(); adapter < adapterCount; adapter++) { D3DADAPTER_IDENTIFIER9 adapterIdentifier; if (pD3D9->GetAdapterIdentifier(adapter, 0, &adapterIdentifier) == D3D_OK) { info += _T(" - ") + CString(adapterIdentifier.Description); if (adapterIdentifier.DriverVersion.QuadPart) { info.AppendFormat(_T(" (driver version: %s)"), FileVersionInfo::FormatVersionString(adapterIdentifier.DriverVersion.LowPart, adapterIdentifier.DriverVersion.HighPart)); } info += _T("\r\n"); } } } // Allocate a global memory object for the text int len = info.GetLength() + 1; HGLOBAL hGlob = GlobalAlloc(GMEM_MOVEABLE, len * sizeof(WCHAR)); if (hGlob) { // Lock the handle and copy the text to the buffer LPVOID pData = GlobalLock(hGlob); if (pData) { wcscpy_s((WCHAR*)pData, len, (LPCWSTR)info); GlobalUnlock(hGlob); if (GetParent()->OpenClipboard()) { // Place the handle on the clipboard, if the call succeeds // the system will take care of the allocated memory if (::EmptyClipboard() && ::SetClipboardData(CF_UNICODETEXT, hGlob)) { hGlob = nullptr; } ::CloseClipboard(); } } if (hGlob) { GlobalFree(hGlob); } } }
void CAboutDlg::OnCopyToClipboard() { CStringW info = m_appname + _T("\r\n"); info += CString(_T('-'), m_appname.GetLength()) + _T("\r\n\r\n"); info += _T("Build information:\r\n"); info += _T(" Version: ") + m_strBuildNumber + _T("\r\n"); info += _T(" Compiler: ") + m_MPCCompiler + _T("\r\n"); info += _T(" Build date: ") + m_buildDate + _T("\r\n\r\n"); #ifndef MPCHC_LITE info += _T("LAV Filters:\r\n"); info += _T(" LAV Splitter: ") + CFGFilterLAV::GetVersion(CFGFilterLAV::SPLITTER) + _T("\r\n"); info += _T(" LAV Video: ") + CFGFilterLAV::GetVersion(CFGFilterLAV::VIDEO_DECODER) + _T("\r\n"); info += _T(" LAV Audio: ") + CFGFilterLAV::GetVersion(CFGFilterLAV::AUDIO_DECODER) + _T("\r\n"); info += _T(" FFmpeg compiler: ") + VersionInfo::GetGCCVersion() + _T("\r\n\r\n"); #endif info += _T("Operating system:\r\n"); info += _T(" Name: ") + m_OSName + _T("\r\n"); info += _T(" Version: ") + m_OSVersion + _T("\r\n\r\n"); info += _T("Hardware:\r\n"); CRegKey key; if (key.Open(HKEY_LOCAL_MACHINE, _T("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"), KEY_READ) == ERROR_SUCCESS) { ULONG nChars = 0; if (key.QueryStringValue(_T("ProcessorNameString"), nullptr, &nChars) == ERROR_SUCCESS) { CString cpuName; if (key.QueryStringValue(_T("ProcessorNameString"), cpuName.GetBuffer(nChars), &nChars) == ERROR_SUCCESS) { cpuName.ReleaseBuffer(nChars); cpuName.Trim(); info.AppendFormat(_T(" CPU: %s\r\n"), cpuName); } } } if (CComPtr<IDirect3D9> pD3D9 = Direct3DCreate9(D3D_SDK_VERSION)) { for (UINT adapter = 0, adapterCount = pD3D9->GetAdapterCount(); adapter < adapterCount; adapter++) { D3DADAPTER_IDENTIFIER9 adapterIdentifier; if (pD3D9->GetAdapterIdentifier(adapter, 0, &adapterIdentifier) == D3D_OK) { CString deviceName = adapterIdentifier.Description; deviceName.Trim(); if (adapterCount > 1) { info.AppendFormat(_T(" GPU%u: %s"), adapter + 1, deviceName); } else { info.AppendFormat(_T(" GPU: %s"), deviceName); } if (adapterIdentifier.DriverVersion.QuadPart) { info.AppendFormat(_T(" (driver version: %s)"), FileVersionInfo::FormatVersionString(adapterIdentifier.DriverVersion.LowPart, adapterIdentifier.DriverVersion.HighPart)); } info += _T("\r\n"); } } } // Allocate a global memory object for the text int len = info.GetLength() + 1; HGLOBAL hGlob = GlobalAlloc(GMEM_MOVEABLE, len * sizeof(WCHAR)); if (hGlob) { // Lock the handle and copy the text to the buffer LPVOID pData = GlobalLock(hGlob); if (pData) { wcscpy_s((WCHAR*)pData, len, (LPCWSTR)info); GlobalUnlock(hGlob); if (GetParent()->OpenClipboard()) { // Place the handle on the clipboard, if the call succeeds // the system will take care of the allocated memory if (::EmptyClipboard() && ::SetClipboardData(CF_UNICODETEXT, hGlob)) { hGlob = nullptr; } ::CloseClipboard(); } } if (hGlob) { GlobalFree(hGlob); } } }