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
| [DllImport("avicap32.dll")]
protected static extern bool capGetDriverDescriptionA(short wDriverIndex,
[MarshalAs(UnmanagedType.VBByRefStr)]ref String lpszName,
int cbName, [MarshalAs(UnmanagedType.VBByRefStr)] ref String lpszVer, int cbVer);
static ArrayList devices = new ArrayList();
public static Device[] GetAllDevices()
{
String dName = "".PadRight(100);
String dVersion = "".PadRight(100);
char[] charsToTrim = { '\0' };
for (short i = 0; i < 10; i++)
{
if (capGetDriverDescriptionA(i, ref dName, 100, ref dVersion, 100))
{
Device d = new Device(i);
d.Name = dName.Trim().TrimEnd(charsToTrim);
d.Version = dVersion.Trim();
devices.Add(d);
}
}
return (Device[])devices.ToArray(typeof(Device));
} |
Partager