Exemplo n.º 1
0
        public string[] PromptForImage(IntPtr parentWindowHandle, WiaDevice device)
        {
            var fileName   = Path.GetRandomFileName();
            var itemHandle = IntPtr.Zero;
            var fileCount  = 0;
            var filePaths  = new string[10];
            var hr         = Version == WiaVersion.Wia10
                ? NativeWiaMethods.GetImage1(Handle, parentWindowHandle, SCANNER_DEVICE_TYPE, 0, 0, Path.Combine(Paths.Temp, fileName), IntPtr.Zero)
                : NativeWiaMethods.GetImage2(Handle, 0, device.Id(), parentWindowHandle, Paths.Temp, fileName, ref fileCount, ref filePaths, ref itemHandle);

            if (hr == 1)
            {
                return(null);
            }
            WiaException.Check(hr);
            return(filePaths ?? new[] { Path.Combine(Paths.Temp, fileName) });
        }