| 16 |
pfowler |
1 |
using System;
|
|
|
2 |
using System.Collections.Generic;
|
|
|
3 |
using System.Linq;
|
|
|
4 |
using System.Text;
|
|
|
5 |
using System.Threading.Tasks;
|
|
|
6 |
using System.Runtime.InteropServices;
|
|
|
7 |
|
|
|
8 |
namespace NITNavComm {
|
|
|
9 |
|
|
|
10 |
public class VolumeControl {
|
|
|
11 |
|
|
|
12 |
[DllImport("VolControlLib.dll")]
|
|
|
13 |
public static extern int _getDevCount(out uint count);
|
|
|
14 |
|
|
|
15 |
[DllImport("VolControlLib.dll",CharSet = CharSet.Ansi,CallingConvention=CallingConvention.StdCall)]
|
|
|
16 |
[return: MarshalAs(UnmanagedType.LPWStr)]
|
|
|
17 |
public static extern string _getDevName(uint dev);
|
|
|
18 |
|
|
|
19 |
[DllImport("VolControlLib.dll")]
|
|
|
20 |
public static extern uint _getDevVolume(uint dev, out float volume);
|
|
|
21 |
|
|
|
22 |
[DllImport("VolControlLib.dll")]
|
|
|
23 |
public static extern uint _setDevVolume(uint dev, float volume);
|
|
|
24 |
|
|
|
25 |
public uint deviceCount { get; set; }
|
|
|
26 |
public List<string> devices { get; set; }
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
public VolumeControl() {
|
|
|
30 |
uint count = 0;
|
|
|
31 |
_getDevCount(out count);
|
|
|
32 |
this.deviceCount = count;
|
|
|
33 |
|
|
|
34 |
devices = new List<string>();
|
|
|
35 |
if (this.deviceCount > 0) {
|
|
|
36 |
for (uint i = 0; i < this.deviceCount; i++) {
|
|
|
37 |
this.devices.Add(this.getDeviceName(i));
|
|
|
38 |
}
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
public String getDeviceName(uint dev) {
|
|
|
44 |
string s = _getDevName(dev);
|
|
|
45 |
return s;
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
public float getDeviceVolume(uint dev) {
|
|
|
49 |
float volume = 0.0F;
|
|
|
50 |
_getDevVolume(dev, out volume);
|
|
|
51 |
return volume;
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
public void setDeviceVolume(uint dev, float volume) {
|
|
|
55 |
_setDevVolume(dev, volume);
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
}
|
|
|
59 |
}
|