Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to change the System's Volume. I am using following code:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace shaped_form
{
class VolumeChange
{
private const int APPCOMMAND_VOLUME_MUTE = 0x80000;
private const int APPCOMMAND_VOLUME_UP = 0xA0000;
private const int APPCOMMAND_VOLUME_DOWN = 0x90000;
private const int WM_APPCOMMAND = 0x319;
[DllImport("user32.dll")]
public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
private void btnMute_Click(object sender, EventArgs e)
{
SendMessageW(this.Handle, WM_APPCOMMAND, this.Handle,(IntPtr)APPCOMMAND_VOLUME_MUTE);
}
private void btnDecVol_Click(object sender, EventArgs e)
{
SendMessageW(this.Handle, WM_APPCOMMAND, this.Handle,(IntPtr)APPCOMMAND_VOLUME_DOWN);
}
private void btnIncVol_Click(object sender, EventArgs e)
{
SendMessageW(this.Handle, WM_APPCOMMAND,this.Handle,(IntPtr)APPCOMMAND_VOLUME_UP);
}
}
}

But I got an error at the highlighted places as "shaped_form.VolumeChange does not contain a definition for Handle". I got this code from some internet sources.
and also please tell me about Intptr and it's importance here.
Posted
Updated 29-Jul-14 1:31am
v5
Comments
ZurdoDev 29-Jul-14 9:41am    
this.handle = From http://msdn.microsoft.com/en-us/library/windows/desktop/ms644950(v=vs.85).aspx, "A handle to the window whose window procedure will receive the message."

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900