Click here to Skip to main content
15,888,579 members
Home / Discussions / C#
   

C#

 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
dasblinkenlight15-Feb-11 2:31
dasblinkenlight15-Feb-11 2:31 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
PIEBALDconsult15-Feb-11 4:19
mvePIEBALDconsult15-Feb-11 4:19 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
dasblinkenlight15-Feb-11 5:15
dasblinkenlight15-Feb-11 5:15 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
PIEBALDconsult15-Feb-11 8:32
mvePIEBALDconsult15-Feb-11 8:32 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
dasblinkenlight15-Feb-11 9:40
dasblinkenlight15-Feb-11 9:40 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
PIEBALDconsult15-Feb-11 10:03
mvePIEBALDconsult15-Feb-11 10:03 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
PIEBALDconsult15-Feb-11 10:09
mvePIEBALDconsult15-Feb-11 10:09 
QuestionControl Speaker Volume Pin
Kevin Marois14-Feb-11 8:21
professionalKevin Marois14-Feb-11 8:21 
I'm using VS 2010 on Windows 7. I found this code in a Google search, and it compiles and runs, but when I pass in values to SetVolume, there is no change in the sound volume:

public static class Volume
{
    [DllImport("winmm.dll")]
    private static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);

    [DllImport("winmm.dll")]
    private static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);

    public static int GetVolume()
    {
        // By the default set the volume to 0
        uint CurrVol = 0;

        // At this point, CurrVol gets assigned the volume
        waveOutGetVolume(IntPtr.Zero, out CurrVol);
                
        // Calculate the volume
        ushort CalcVol = (ushort)(CurrVol & 0x0000ffff);
                
        // Get the volume on a scale of 1 to 10 (to fit the trackbar)
        int volume = CalcVol / (ushort.MaxValue / 10);

        return volume;
    }

    public static void SetVolume(int Volume)
    {
        // Calculate the volume that's being set
        int NewVolume = ((ushort.MaxValue / 10) * Volume);

        // Set the same volume for both the left and the right channels
        uint NewVolumeAllChannels = (((uint)NewVolume & 0x0000ffff) | ((uint)NewVolume << 16));
                
        // Set the volume
        waveOutSetVolume(IntPtr.Zero, NewVolumeAllChannels);
    }
}


I found a couple of Mixer type projects here on CP, but they're over the top as far as wat I'm looking for. I simply want to change the volume level of the speakers.

Anyone know how to do this?
>
Everything makes sense in someone's mind

AnswerRe: Control Speaker Volume Pin
DaveyM6914-Feb-11 9:15
professionalDaveyM6914-Feb-11 9:15 
GeneralRe: Control Speaker Volume Pin
Kevin Marois14-Feb-11 10:27
professionalKevin Marois14-Feb-11 10:27 
GeneralRe: Control Speaker Volume Pin
DaveyM6914-Feb-11 10:58
professionalDaveyM6914-Feb-11 10:58 
GeneralRe: Control Speaker Volume Pin
Kevin Marois14-Feb-11 11:03
professionalKevin Marois14-Feb-11 11:03 
GeneralRe: Control Speaker Volume Pin
Kevin Marois14-Feb-11 11:36
professionalKevin Marois14-Feb-11 11:36 
GeneralRe: Control Speaker Volume Pin
DaveyM6914-Feb-11 11:45
professionalDaveyM6914-Feb-11 11:45 
GeneralRe: Control Speaker Volume Pin
Kevin Marois14-Feb-11 11:49
professionalKevin Marois14-Feb-11 11:49 
GeneralRe: Control Speaker Volume Pin
DaveyM6914-Feb-11 11:58
professionalDaveyM6914-Feb-11 11:58 
GeneralRe: Control Speaker Volume Pin
DaveyM6914-Feb-11 15:08
professionalDaveyM6914-Feb-11 15:08 
GeneralRe: Control Speaker Volume Pin
Kevin Marois15-Feb-11 5:48
professionalKevin Marois15-Feb-11 5:48 
GeneralRe: Control Speaker Volume Pin
DaveyM6914-Feb-11 11:04
professionalDaveyM6914-Feb-11 11:04 
GeneralRe: Control Speaker Volume Pin
Kevin Marois14-Feb-11 11:08
professionalKevin Marois14-Feb-11 11:08 
QuestionReport Progress from a class with a backgroundWorker Pin
MacRaider414-Feb-11 7:34
MacRaider414-Feb-11 7:34 
AnswerRe: Report Progress from a class with a backgroundWorker Pin
Luc Pattyn14-Feb-11 7:42
sitebuilderLuc Pattyn14-Feb-11 7:42 
GeneralRe: Report Progress from a class with a backgroundWorker Pin
MacRaider414-Feb-11 7:57
MacRaider414-Feb-11 7:57 
GeneralRe: Report Progress from a class with a backgroundWorker Pin
Luc Pattyn14-Feb-11 8:13
sitebuilderLuc Pattyn14-Feb-11 8:13 
GeneralRe: Report Progress from a class with a backgroundWorker Pin
MacRaider414-Feb-11 8:21
MacRaider414-Feb-11 8:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.