Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- 티스토리 초대
- WebView
- 인코딩
- udp
- Tomcat
- HTML
- ios
- Eclipse
- spring
- 톰켓
- 메모리
- permgen space
- Android
- Database
- C#
- MySQL
- java
- 이클립스
- 티스토리 초대장
- encoding
- jQuery
- Memory
- Objective C
- UIWebView
- jsp
- 한글
- JavaScript
- ipad
- iphone
- XML
Archives
- Today
- Total
suroMind
[C#] Sound Volume Control 본문
Visual Studio 2010에서 테스트하였습니다.
TrackBar의 Minimum값은 0 , Maximum값은 10으로 셋팅하여 테스트 하였습니다.
출처 : http://www.geekpedia.com/tutorial176_Get-and-set-the-wave-sound-volume.html
using System;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication2 {
public class Win32 {
#region 사운드 관련
[DllImport("winmm.dll")]
public static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);
[DllImport("winmm.dll")]
public static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);
public static void SetSoundVolume(int volume) {
try {
int newVolume = ((ushort.MaxValue / 10) * volume);
uint newVolumeAllChannels = (((uint)newVolume & 0x0000ffff) | ((uint)newVolume << 16));
waveOutSetVolume(IntPtr.Zero, newVolumeAllChannels);
} catch (Exception) { }
}
public static int GetSoundVolume() {
int value = 0;
try {
uint CurrVol = 0;
waveOutGetVolume(IntPtr.Zero, out CurrVol);
ushort CalcVol = (ushort)(CurrVol & 0x0000ffff);
value = CalcVol / (ushort.MaxValue / 10);
} catch (Exception) { }
return value;
}
#endregion
}
}
TrackBar 의 Value에 바로 SetSoundVolume() 또는 GetSoundVolume()으로 표현하면 됩니다.TrackBar의 Minimum값은 0 , Maximum값은 10으로 셋팅하여 테스트 하였습니다.
출처 : http://www.geekpedia.com/tutorial176_Get-and-set-the-wave-sound-volume.html
'IT분야 > C#' 카테고리의 다른 글
| [C#]DateTime ToString() 변환 패턴 (0) | 2012.01.04 |
|---|---|
| [C#] log4net 설정 및 사용 (0) | 2011.12.09 |
| [C#] 배경 투명하게 만들기 (2) | 2011.11.09 |
| [C#] XML 직렬화 클래스 사용 예제 (0) | 2011.11.03 |
| [C#] 윈도우 시작시 프로그램 자동 실행 레지스트리 등록 (0) | 2011.11.03 |
Comments