public string[]? PromptForImage(IntPtr parentWindowHandle, WiaDevice device, string?tempFolder = null) { tempFolder ??= Path.GetTempPath(); var fileName = Path.GetRandomFileName(); IntPtr itemHandle = IntPtr.Zero; int fileCount = 0; string[] filePaths = new string[0]; var hr = Version == WiaVersion.Wia10 ? NativeWiaMethods.GetImage1(Handle, parentWindowHandle, SCANNER_DEVICE_TYPE, 0, 0, Path.Combine(tempFolder, fileName), IntPtr.Zero) : NativeWiaMethods.GetImage2(Handle, 0, device.Id(), parentWindowHandle, tempFolder, fileName, ref fileCount, ref filePaths, ref itemHandle); if (hr == 1) { return(null); } WiaException.Check(hr); return(filePaths ?? new[] { Path.Combine(tempFolder, fileName) }); }
public WiaItem?PromptToConfigure(IntPtr parentWindowHandle) { if (Version == WiaVersion.Wia20) { throw new InvalidOperationException("WIA 2.0 does not support PromptToConfigure. Use WiaDeviceManager.PromptForImage if you want to use the native WIA 2.0 UI."); } int itemCount = 0; IntPtr[]? items = null; var hr = NativeWiaMethods.ConfigureDevice1(Handle, parentWindowHandle, 0, 0, ref itemCount, ref items); if (hr == 1) { return(null); } WiaException.Check(hr); if (items == null) { return(null); } return(new WiaItem(Version, items[0])); }
protected internal WiaPropertyCollection(WiaVersion version, IntPtr propertyStorageHandle) : base(version, propertyStorageHandle) { _propertyDict = new Dictionary <int, WiaProperty>(); WiaException.Check(NativeWiaMethods.EnumerateProperties(Handle, (id, name, type) => _propertyDict.Add(id, new WiaProperty(Handle, id, name, type)))); }