我想使用C#应用程序从网络摄像头拍摄照片。首先,我将获得PC上所有网络摄像头的列表。我找到了这个例子:
System.Collections.Generic.List<DeviceInfoClass> devs =
new List<DeviceInfoClass>();
WIA.Collection devsCol =
this.WiaObj.Devices as WIALib.CollectionClass;
foreach (object obj in devsCol)
{
WIA.DeviceInfoClass dev = (WIA.DeviceInfoClass)
System.Runtime.InteropServices.Marshal.CreateWrapperOfType(
obj, typeof(WIA.DeviceInfoClass));
if (dev.Type.Contains("Video") == true)
{
devs.Add(dev);
}
else
{
Marshal.FinalReleaseComObject(obj);
Marshal.FinalReleaseComObject(dev);
}
}
Devices = devs.ToArray();
if (Devices.Length > 0)
{
DefaultDevice = Devices[0];
}
else
{
throw new Exception("No Cameras Detected");
}
Marshal.FinalReleaseComObject(devsCol);
GC.ReRegisterForFinalize(devs);
但问题是我有Win 7并使用Wia 2.0(wiaut.dll)并且没有CollectionClass。 那么,如何使用WiA 2.0(wiaut.dll)获取所有网络摄像头的列表?