Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6355479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:46:22+00:00 2026-05-24T22:46:22+00:00

In Windows 7 there are multiple playback devices. Example (on my laptop): Speakers and

  • 0

In Windows 7 there are multiple playback devices.

Example (on my laptop):
Speakers and Dual Headphones
Independent Dual Headphones
SPDIF (Digital Out via HP Dock)

The situation is thus:
I am writing an app that lets the user choose the output device and save this into the settings of the app. So it offers the user a choice of all Directsound devices in a combobox. The user selects the one he prefers and saves it.

My requirement is:
On initial load of this list, I want to select the default device (as set in Windows 7 – Control Panel -> Sound -> Playback tab)

So my code to enumerate the audio output devices is:

Code:

procedure TForm1.FillDevices;
var
  AudioDevEnum: TSysDevEnum;
  n: string;
  i, ps: integer;
begin

  AudioDevEnum := TSysDevEnum.Create(CLSID_AudioRendererCategory);
  try

    if AudioDevEnum.CountFilters = 0 then
      Exit;

    for i := 0 to AudioDevEnum.CountFilters - 1 do
    begin
      n  := AudioDevEnum.Filters[i].FriendlyName;
      ps := pos('DirectSound: ', n);
      if ps <> 0 then
      begin
        ps := pos('Modem', n);
        if ps = 0 then
        begin
          // Delete(n, 1, 13);
          lstDevices.Items.Add(n);
        end;
      end;
    end;
    lstDevices.ItemIndex := 0;

  finally
    AudioDevEnum.Free;
  end;
end;

After getting the list, I want to detect the item which is set as the ‘default device’ in the sound control panel, and select it. This is so that application saves the correct device the first time without needing the user to do this job.

Can this be done? How?

Thanks in advance.

EDIT: Note that I want to select and save (to INI file) the default device so that it can be used by my application to output sound (via the DSPack component). I do not want to change the Windows setting.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:46:22+00:00Added an answer on May 24, 2026 at 10:46 pm

    Here’s a method that queries the driver for preferred playback device(http://msdn.microsoft.com/en-us/library/aa909815.aspx), GetWaveOutDeviceList will return the list of devices, GetWaveOutDevice will return the index in the list of the prefered device.

    // this method will return the index in the list
    function GetWaveOutDevice: Cardinal;
    const
      DRVM_MAPPER=$2000;
      DRVM_MAPPER_PREFERRED_GET = DRVM_MAPPER + 21;
      DRVM_MAPPER_PREFERRED_SET = DRVM_MAPPER + 22;
    var
     LDW2: Cardinal;
    begin
     Result := $FFFFFFFF;
     LDW2 := 0;
     waveOutMessage( WAVE_MAPPER, DRVM_MAPPER_PREFERRED_GET, DWORD( @Result ), DWORD( @LDW2 ) );
    end;
    
    // this method will retrieve the list of devices
    procedure GetWaveOutDeviceList(List: TStrings);
    var
     Index: Integer;
     LCaps: WAVEOUTCAPS;
    begin
      List.Clear;
      for Index := 0 to waveOutGetNumDevs -1 do begin
        waveOutGetDevCaps( Index, @LCaps, SizeOf( LCaps ) );
        List.add( LCaps.szPname );
      end;
    end;
    

    If you would like to get the recording devices, just replace “WaveOut” with “WaveIn” in the above to methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there are multiple solutions online, but some are for windows, some are
Is there a way to apply consistent visual appearance for multiple Windows Forms applications?
Is there a Windows (or .NET) synchronization primitive that: can be shared across multiple
Sorry for the Windows developers out there, this solution is for Macs only. This
I'm trying to understand how modal windows work. I know, there are multiple plug-ins
There's a WPF application with multiple windows. Initially there's only one window. User may
Is there a shortcut key for editing multiple lines in RubyMine (Windows) as you
For example on windows there is MsgWaitForMultipleObjects that lets you asynchronously wait for windows
For example if there are multiple executable files on the path i.e., a.exe, a.bat
I have a Windows service that continuously performs calculation tasks. There are multiple calculation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.