Changeset 619 for trunk/Utilities


Ignore:
Timestamp:
Apr 17, 2016, 12:04:20 PM (8 years ago)
Author:
roman
Message:

Added IMMDevice::Activate output

Location:
trunk/Utilities/EnumerateAudioDevices
Files:
2 added
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/EnumerateAudioDevices/AboutDialog.h

    r11 r619  
    11////////////////////////////////////////////////////////////
    2 // AboutDialog.h -
    3 //
     2// Copyright (C) Roman Ryltsov, 2006-2016
    43// 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.
    77
    88#pragma once
    99
     10#include <atlsecurity.h>
    1011#include <atlctrls.h>
    1112#include <atlctrlx.h>
     
    2122{
    2223public:
    23 
    2424        enum { IDD = IDD_ABOUT };
    2525
     
    3939public:
    4040// CAboutDialog
    41         CAboutDialog() throw()
     41        static CFontHandle CreateTitleFont()
    4242        {
    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();
    4451        }
    45         ~CAboutDialog() throw()
     52        static CFontHandle CreateDisclaimerFont()
    4653        {
    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);
    4898        }
    4999
    50 // Window message handlers
     100// Window Message Handler
    51101        LRESULT OnInitDialog(HWND, LPARAM)
    52102        {
    53103                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
    55109                {
    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();
    71111                        CStatic CopyrightWarningText = GetDlgItem(IDC_ABOUT_COPYRIGHTWARNING);
    72112                        CopyrightWarningText.SetFont(m_DisclaimerFont);
     
    90130                        }
    91131                }
    92                 // Update version text
     132                #pragma endregion
     133                #pragma region Version Text
    93134                CStatic ProductVersionStatic = GetDlgItem(IDC_ABOUT_PRODUCTVERSION), FileVersionStatic = GetDlgItem(IDC_ABOUT_FILEVERSION);
    94135                CString sProductVersionFormat, sFileVersionFormat;
     
    98139                ProductVersionStatic.SetWindowText(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetProductVersion(sModulePath), sProductVersionFormat));
    99140                FileVersionStatic.SetWindowText(_VersionInfoHelper::GetVersionString(_VersionInfoHelper::GetFileVersion(sModulePath), sFileVersionFormat));
    100                 // Update hyperlinks
     141                #pragma endregion
     142                #pragma region Hyperlinks
    101143                _W(m_WebsiteHyperStatic.SubclassWindow(GetDlgItem(IDC_ABOUT_WEBSITE)));
    102144                _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
    117148                _W(CenterWindow(GetParent()));
    118149                GetDlgItem(IDOK).SetFocus();
     150                #pragma endregion
    119151                return FALSE;
    120152        }
    121         LRESULT OnDestroy() throw()
     153        LRESULT OnDestroy()
    122154        {
    123155                _W(m_TitleFont.DeleteObject());
     
    125157                return 0;
    126158        }
    127         LRESULT OnCommand(UINT, INT nIdentifier, HWND) throw()
     159        LRESULT OnCommand(UINT, INT nIdentifier, HWND)
    128160        {
    129161                _W(EndDialog(nIdentifier));
  • trunk/Utilities/EnumerateAudioDevices/EnumerateAudioDevices.vcxproj

    r522 r619  
    298298  </ItemDefinitionGroup>
    299299  <ItemGroup>
    300     <ClCompile Include="EnumerateAudioDevices.cpp" />
     300    <ClCompile Include="Application.cpp" />
    301301    <ClCompile Include="stdafx.cpp">
    302302      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
     
    312312  </ItemGroup>
    313313  <ItemGroup>
    314     <None Include="EnumerateAudioDevices.ico" />
    315314    <None Include="Module.ico" />
    316315  </ItemGroup>
    317316  <ItemGroup>
    318     <ResourceCompile Include="EnumerateAudioDevices.rc" />
     317    <ResourceCompile Include="Module.rc" />
    319318  </ItemGroup>
    320319  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  • trunk/Utilities/EnumerateAudioDevices/EnumerateAudioDevices.vcxproj.filters

    r11 r619  
    1616  </ItemGroup>
    1717  <ItemGroup>
    18     <ClCompile Include="EnumerateAudioDevices.cpp">
     18    <ClCompile Include="stdafx.cpp">
    1919      <Filter>Source Files</Filter>
    2020    </ClCompile>
    21     <ClCompile Include="stdafx.cpp">
     21    <ClCompile Include="Application.cpp">
    2222      <Filter>Source Files</Filter>
    2323    </ClCompile>
     
    3535  </ItemGroup>
    3636  <ItemGroup>
    37     <None Include="EnumerateAudioDevices.ico">
    38       <Filter>Resource Files</Filter>
    39     </None>
    4037    <None Include="Module.ico">
    4138      <Filter>Resource Files</Filter>
     
    4340  </ItemGroup>
    4441  <ItemGroup>
    45     <ResourceCompile Include="EnumerateAudioDevices.rc">
     42    <ResourceCompile Include="Module.rc">
    4643      <Filter>Resource Files</Filter>
    4744    </ResourceCompile>
  • trunk/Utilities/EnumerateAudioDevices/MainDialog.h

    r590 r619  
    55#pragma once
    66
     7#include "rodshow.h"
    78#include <mmdeviceapi.h>
    89#include <mmreg.h>
     
    1112#include <devpkey.h>
    1213#include <devicetopology.h>
     14#include <audioclient.h>
     15#include <endpointvolume.h>
     16#include <audiopolicy.h>
     17//#include <dsound.h>
    1318#include "AboutDialog.h"
    1419
     
    6065        }
    6166
    62 // Window message handelrs
    63         LRESULT OnInitDialog(HWND, LPARAM) throw()
     67// Window Message Handler
     68        LRESULT OnInitDialog(HWND, LPARAM)
    6469        {
    6570                SetIcon(AtlLoadIcon(IDI_MODULE), TRUE);
     
    6974                _W(Menu.AppendMenu(MF_STRING, ID_APP_ABOUT, _T("&About...")));
    7075                DlgResize_Init();
     76                CAboutDialog::UpdateCaption(*this);
    7177                _W(CenterWindow());
    7278                _ATLTRY
     
    105111                                                };
    106112                                                sText.AppendFormat(_T("\t") _T("State\t%s\t0x%02X\r\n"), FormatFlagsT(g_pDeviceStateMap, nState), nState);
    107                                                 #pragma endregion State
     113                                                #pragma endregion
    108114                                                #pragma region Property Store
    109115                                                sText.AppendFormat(_T("\t") _T("Properties:\r\n"));
     
    13581364                                                                                CComPtr<IKsJackDescription> jack;
    13591365                                                                                hr = part->Activate(CLSCTX_ALL, IID_PPV_ARGS(&jack));
    1360                                                                                 if (SUCCEEDED(hr))
     1366                                                                                if(SUCCEEDED(hr))
    13611367                                                                                {
     1368                                                                                        sText.AppendFormat(_T("\t") _T("Device Topology\r\n"));
    13621369                                                                                        UINT jackCount = 0;
    13631370                                                                                        jack->GetJackCount(&jackCount);
    1364                                                                                         for (int j = 0; j < jackCount; j++)
     1371                                                                                        for(UINT j = 0; j < jackCount; j++)
    13651372                                                                                        {
    13661373                                                                                                KSJACK_DESCRIPTION desc = { 0 };
     
    13791386                                                {
    13801387                                                        _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);
    13811414                                                }
    13821415                                                #pragma endregion
  • trunk/Utilities/EnumerateAudioDevices/stdafx.h

    r522 r619  
    1111
    1212#define INLINE_HRESULT_FROM_WIN32
     13#define _INC_WINDOWSX
    1314
    1415////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.