Changeset 619
- Timestamp:
- Apr 17, 2016, 12:04:20 PM (7 years ago)
- Location:
- trunk/Utilities/EnumerateAudioDevices
- Files:
-
- 2 added
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Utilities/EnumerateAudioDevices/AboutDialog.h
r11 r619 1 1 //////////////////////////////////////////////////////////// 2 // AboutDialog.h - 3 // 2 // Copyright (C) Roman Ryltsov, 2006-2016 4 3 // Created by Roman Ryltsov roman@alax.info 5 // 6 // $Id$ 4 // 5 // A permission to use the source code is granted as long as reference to 6 // source website http://alax.info is retained. 7 7 8 8 #pragma once 9 9 10 #include <atlsecurity.h> 10 11 #include <atlctrls.h> 11 12 #include <atlctrlx.h> … … 21 22 { 22 23 public: 23 24 24 enum { IDD = IDD_ABOUT }; 25 25 … … 39 39 public: 40 40 // CAboutDialog 41 CAboutDialog() throw()41 static CFontHandle CreateTitleFont() 42 42 { 43 _Z4(atlTraceRefcount, 4, _T("this 0x%08x\n"), this); 43 CLogFont LogFont; 44 LogFont.lfHeight = -MulDiv(12, GetDeviceCaps(CClientDC(GetDesktopWindow()), LOGPIXELSY), 72); 45 LogFont.lfWeight = FW_BOLD; 46 LogFont.lfItalic = TRUE; 47 _tcsncpy_s(LogFont.lfFaceName, _T("Arial"), _TRUNCATE); 48 CFont Font; 49 _W(Font.CreateFontIndirect(&LogFont)); 50 return Font.Detach(); 44 51 } 45 ~CAboutDialog() throw()52 static CFontHandle CreateDisclaimerFont() 46 53 { 47 _Z4(atlTraceRefcount, 4, _T("this 0x%08x\n"), this); 54 CLogFont LogFont; 55 LogFont.lfHeight = -MulDiv(7, GetDeviceCaps(CClientDC(GetDesktopWindow()), LOGPIXELSY), 72); 56 LogFont.lfWeight = FW_NORMAL; 57 _tcsncpy_s(LogFont.lfFaceName, _T("Lucida Console"), _TRUNCATE); 58 CFont Font; 59 _W(Font.CreateFontIndirect(&LogFont)); 60 return Font.Detach(); 61 } 62 CAboutDialog() 63 { 64 _Z4_THIS(); 65 } 66 ~CAboutDialog() 67 { 68 _Z4_THIS(); 69 } 70 static BOOL IsAdministrator() 71 { 72 bool bIsMember = FALSE; 73 return CAccessToken().CheckTokenMembership(Sids::Admins(), &bIsMember) && bIsMember; 74 } 75 static VOID UpdateCaption(CWindow Window) 76 { 77 CString sCaption; 78 _W(Window.GetWindowText(sCaption)); 79 CRoArrayT<CString> SpecifierArray; 80 #if defined(_WIN64) 81 SpecifierArray.Add(_T("64-bit")); 82 #else 83 if(SafeIsWow64Process()) 84 SpecifierArray.Add(_T("32-bit")); 85 #endif // defined(_WIN64) 86 if(IsWindowsVistaOrGreater() && IsAdministrator()) 87 SpecifierArray.Add(_T("Administrator")); 88 if(!SpecifierArray.IsEmpty()) 89 sCaption = AtlFormatString(_T("%s (%s)"), sCaption, _StringHelper::Join(SpecifierArray, _T(", "))); 90 #if _TRACE 91 sCaption.Append(_T(" // ")); 92 #if _DEVELOPMENT 93 sCaption.Append(_T("Dev ")); 94 #endif // _DEVELOPMENT 95 sCaption.Append(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetFileVersion(_VersionInfoHelper::GetModulePath()))); 96 #endif // _TRACE 97 Window.SetWindowText(sCaption); 48 98 } 49 99 50 // Window message handlers100 // Window Message Handler 51 101 LRESULT OnInitDialog(HWND, LPARAM) 52 102 { 53 103 CStatic(GetDlgItem(IDC_ABOUT_ICON)).SetIcon(AtlLoadIconImage(IDI_MODULE, LR_DEFAULTCOLOR, 48, 48)); 54 // Create and apply title font 104 #pragma region Title Font 105 m_TitleFont = CreateTitleFont(); 106 CStatic(GetDlgItem(IDC_ABOUT_TITLE)).SetFont(m_TitleFont); 107 #pragma endregion 108 #pragma region Disclaimer Font 55 109 { 56 CLogFont LogFont; 57 LogFont.lfHeight = -MulDiv(12, GetDeviceCaps(CClientDC(m_hWnd), LOGPIXELSY), 72); 58 LogFont.lfWeight = FW_BOLD; 59 LogFont.lfItalic = TRUE; 60 _tcsncpy_s(LogFont.lfFaceName, _countof(LogFont.lfFaceName), _T("Arial"), _TRUNCATE); 61 _W(m_TitleFont.CreateFontIndirect(&LogFont)); 62 CStatic(GetDlgItem(IDC_ABOUT_TITLE)).SetFont(m_TitleFont); 63 } 64 // Create and apply disclaimer font 65 { 66 CLogFont LogFont; 67 LogFont.lfHeight = -MulDiv(7, GetDeviceCaps(CClientDC(m_hWnd), LOGPIXELSY), 72); 68 LogFont.lfWeight = FW_NORMAL; 69 _tcsncpy_s(LogFont.lfFaceName, _countof(LogFont.lfFaceName), _T("Lucida Console"), _TRUNCATE); 70 _W(m_DisclaimerFont.CreateFontIndirect(&LogFont)); 110 m_DisclaimerFont = CreateDisclaimerFont(); 71 111 CStatic CopyrightWarningText = GetDlgItem(IDC_ABOUT_COPYRIGHTWARNING); 72 112 CopyrightWarningText.SetFont(m_DisclaimerFont); … … 90 130 } 91 131 } 92 // Update version text 132 #pragma endregion 133 #pragma region Version Text 93 134 CStatic ProductVersionStatic = GetDlgItem(IDC_ABOUT_PRODUCTVERSION), FileVersionStatic = GetDlgItem(IDC_ABOUT_FILEVERSION); 94 135 CString sProductVersionFormat, sFileVersionFormat; … … 98 139 ProductVersionStatic.SetWindowText(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetProductVersion(sModulePath), sProductVersionFormat)); 99 140 FileVersionStatic.SetWindowText(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetFileVersion(sModulePath), sFileVersionFormat)); 100 // Update hyperlinks 141 #pragma endregion 142 #pragma region Hyperlinks 101 143 _W(m_WebsiteHyperStatic.SubclassWindow(GetDlgItem(IDC_ABOUT_WEBSITE))); 102 144 _W(m_EmailHyperStatic.SubclassWindow(GetDlgItem(IDC_ABOUT_EMAIL))); 103 // Update caption 104 { 105 #if _TRACE 106 CString sCaption; 107 _W(GetWindowText(sCaption)); 108 sCaption.Append(_T(" // ")); 109 #if _DEVELOPMENT 110 sCaption.Append(_T("Dev ")); 111 #endif // _DEVELOPMENT 112 sCaption.Append(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetFileVersion(_VersionInfoHelper::GetModulePath()))); 113 _W(SetWindowText(sCaption)); 114 #endif // _TRACE 115 } 116 // Update window position and focus 145 #pragma endregion 146 UpdateCaption(*this); 147 #pragma region Window Position and Focus 117 148 _W(CenterWindow(GetParent())); 118 149 GetDlgItem(IDOK).SetFocus(); 150 #pragma endregion 119 151 return FALSE; 120 152 } 121 LRESULT OnDestroy() throw()153 LRESULT OnDestroy() 122 154 { 123 155 _W(m_TitleFont.DeleteObject()); … … 125 157 return 0; 126 158 } 127 LRESULT OnCommand(UINT, INT nIdentifier, HWND) throw()159 LRESULT OnCommand(UINT, INT nIdentifier, HWND) 128 160 { 129 161 _W(EndDialog(nIdentifier)); -
trunk/Utilities/EnumerateAudioDevices/EnumerateAudioDevices.vcxproj
r522 r619 298 298 </ItemDefinitionGroup> 299 299 <ItemGroup> 300 <ClCompile Include=" EnumerateAudioDevices.cpp" />300 <ClCompile Include="Application.cpp" /> 301 301 <ClCompile Include="stdafx.cpp"> 302 302 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> … … 312 312 </ItemGroup> 313 313 <ItemGroup> 314 <None Include="EnumerateAudioDevices.ico" />315 314 <None Include="Module.ico" /> 316 315 </ItemGroup> 317 316 <ItemGroup> 318 <ResourceCompile Include=" EnumerateAudioDevices.rc" />317 <ResourceCompile Include="Module.rc" /> 319 318 </ItemGroup> 320 319 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> -
trunk/Utilities/EnumerateAudioDevices/EnumerateAudioDevices.vcxproj.filters
r11 r619 16 16 </ItemGroup> 17 17 <ItemGroup> 18 <ClCompile Include=" EnumerateAudioDevices.cpp">18 <ClCompile Include="stdafx.cpp"> 19 19 <Filter>Source Files</Filter> 20 20 </ClCompile> 21 <ClCompile Include=" stdafx.cpp">21 <ClCompile Include="Application.cpp"> 22 22 <Filter>Source Files</Filter> 23 23 </ClCompile> … … 35 35 </ItemGroup> 36 36 <ItemGroup> 37 <None Include="EnumerateAudioDevices.ico">38 <Filter>Resource Files</Filter>39 </None>40 37 <None Include="Module.ico"> 41 38 <Filter>Resource Files</Filter> … … 43 40 </ItemGroup> 44 41 <ItemGroup> 45 <ResourceCompile Include=" EnumerateAudioDevices.rc">42 <ResourceCompile Include="Module.rc"> 46 43 <Filter>Resource Files</Filter> 47 44 </ResourceCompile> -
trunk/Utilities/EnumerateAudioDevices/MainDialog.h
r590 r619 5 5 #pragma once 6 6 7 #include "rodshow.h" 7 8 #include <mmdeviceapi.h> 8 9 #include <mmreg.h> … … 11 12 #include <devpkey.h> 12 13 #include <devicetopology.h> 14 #include <audioclient.h> 15 #include <endpointvolume.h> 16 #include <audiopolicy.h> 17 //#include <dsound.h> 13 18 #include "AboutDialog.h" 14 19 … … 60 65 } 61 66 62 // Window message handelrs63 LRESULT OnInitDialog(HWND, LPARAM) throw()67 // Window Message Handler 68 LRESULT OnInitDialog(HWND, LPARAM) 64 69 { 65 70 SetIcon(AtlLoadIcon(IDI_MODULE), TRUE); … … 69 74 _W(Menu.AppendMenu(MF_STRING, ID_APP_ABOUT, _T("&About..."))); 70 75 DlgResize_Init(); 76 CAboutDialog::UpdateCaption(*this); 71 77 _W(CenterWindow()); 72 78 _ATLTRY … … 105 111 }; 106 112 sText.AppendFormat(_T("\t") _T("State\t%s\t0x%02X\r\n"), FormatFlagsT(g_pDeviceStateMap, nState), nState); 107 #pragma endregion State113 #pragma endregion 108 114 #pragma region Property Store 109 115 sText.AppendFormat(_T("\t") _T("Properties:\r\n")); … … 1358 1364 CComPtr<IKsJackDescription> jack; 1359 1365 hr = part->Activate(CLSCTX_ALL, IID_PPV_ARGS(&jack)); 1360 if 1366 if(SUCCEEDED(hr)) 1361 1367 { 1368 sText.AppendFormat(_T("\t") _T("Device Topology\r\n")); 1362 1369 UINT jackCount = 0; 1363 1370 jack->GetJackCount(&jackCount); 1364 for (intj = 0; j < jackCount; j++)1371 for(UINT j = 0; j < jackCount; j++) 1365 1372 { 1366 1373 KSJACK_DESCRIPTION desc = { 0 }; … … 1379 1386 { 1380 1387 _Z_EXCEPTION(); 1388 } 1389 #pragma endregion 1390 #pragma region Activation 1391 sText.AppendFormat(_T("\t") _T("Activation") _T("\r\n")); 1392 static const CEnumerationNameT<IID> g_pMap[] = 1393 { 1394 #define A(x) { __uuidof(x), #x }, 1395 A(IAudioClient) 1396 A(IAudioEndpointVolume) 1397 A(IAudioMeterInformation) 1398 A(IAudioSessionManager) 1399 A(IAudioSessionManager2) 1400 A(IBaseFilter) 1401 A(IDeviceTopology) 1402 //A(IDirectSound) 1403 //A(IDirectSound8) 1404 //A(IDirectSoundCapture) 1405 //A(IDirectSoundCapture8) 1406 A(IMFTrustedOutput) 1407 #undef A 1408 }; 1409 for(auto&& Item: g_pMap) 1410 { 1411 CComPtr<IUnknown> pUnknown; 1412 const HRESULT nActivateResult = pMmDevice->Activate(Item.Value, CLSCTX_ALL, NULL, (VOID**) &pUnknown); 1413 sText.AppendFormat(_T("\t") _T("\t") _T("%hs") _T("\t") _T("0x%08X") _T("\r\n"), Item.pszName, nActivateResult); 1381 1414 } 1382 1415 #pragma endregion -
trunk/Utilities/EnumerateAudioDevices/stdafx.h
r522 r619 11 11 12 12 #define INLINE_HRESULT_FROM_WIN32 13 #define _INC_WINDOWSX 13 14 14 15 ////////////////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.