使用EZTW32.DLL
声明:
[DllImport("user32.DLL", ExactSpelling=true)]
internal static extern long SetForegroundWindow(IntPtr hWnd);
[DllImport("EZTW32.DLL", ExactSpelling=true)]
internal static extern long TWAIN_AcquireToClipboard(IntPtr handle,long t);
[DllImport("EZTW32.DLL", ExactSpelling=true)]
internal static extern long TWAIN_SelectImageSource(IntPtr handle);
[DllImport("EZTW32.DLL", ExactSpelling=true)]
internal static extern long TWAIN_IsAvailable();
[DllImport("EZTW32.DLL", ExactSpelling=true)]
internal static extern long TWAIN_SetHideUI(long nHide);照相:
if ( TWAIN_AcquireToClipboard(this.Handle,(long)4) == 0 )
{
SetForegroundWindow(this.Handle);
return;
}
SetForegroundWindow(this.Handle);
Image img = (Image)Clipboard.GetDataObject().GetData(DataFormats.Bitmap);
if ( img == null ) return;
this.picImage.SizeMode = PictureBoxSizeMode.StretchImage;
this.picImage.Image = img;