Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
namespace NITNavComm {
public class VolumeControl {
[DllImport("VolControlLib.dll")]
public static extern int _getDevCount(out uint count);
[DllImport("VolControlLib.dll",CharSet = CharSet.Ansi,CallingConvention=CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.LPWStr)]
public static extern string _getDevName(uint dev);
[DllImport("VolControlLib.dll")]
public static extern uint _getDevVolume(uint dev, out float volume);
[DllImport("VolControlLib.dll")]
public static extern uint _setDevVolume(uint dev, float volume);
public uint deviceCount { get; set; }
public List<string> devices { get; set; }
public VolumeControl() {
uint count = 0;
_getDevCount(out count);
this.deviceCount = count;
devices = new List<string>();
if (this.deviceCount > 0) {
for (uint i = 0; i < this.deviceCount; i++) {
this.devices.Add(this.getDeviceName(i));
}
}
}
public String getDeviceName(uint dev) {
string s = _getDevName(dev);
return s;
}
public float getDeviceVolume(uint dev) {
float volume = 0.0F;
_getDevVolume(dev, out volume);
return volume;
}
public void setDeviceVolume(uint dev, float volume) {
_setDevVolume(dev, volume);
}
}
}