如何从silverlight访问扫描仪? [英] How to access scanner from silverlight?

查看:97
本文介绍了如何从silverlight访问扫描仪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我使用Silverlight 5并使用以下代码进行扫描,它在win 8上工作正常,但在Windows XP上它不起作用,

任何人都可以帮助我吗?



 私人  void  Button_Click_1( object  sender,RoutedEventArgs e)
{
try
{
使用动态 CommonDialog = AutomationFactory.CreateObject( WIA.CommonDialog))
{
dynamic imageFile = CommonDialog.ShowAcquireImage();
if (imageFile!= null
{
if (!Directory.Exists( D:\\ ScanImage))
{
Directory.CreateDirectory( D:\ \ScanImage);
}
string filePath = string .Format( D:\\ScanImage \\ {0} .jpg,Guid.NewGuid());
imageFile.SaveFile(filePath);
}
}
}
catch (System.Runtime.InteropServices.COMException ex)
{
if (ex.ErrorCode == -2145320939)
{
MessageBox.Show( 找不到附加的扫描仪。 扫描程序错误,MessageBoxButton.OK);
}
else
{
MessageBox.Show(ex.Message, 扫描程序错误,MessageBoxButton.OK);
}
}

}

解决方案

检查扫描仪库是否已注册在Windows XP计算机上。

还要确保该计算机上有正确版本的Silverlight。


•更改注册表项HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \Silverlight调试值为1


如果启用了silverlight或者注册表设置为1,则可能是因为它是Windows 8中的默认设置,因此您未在Windows XP中配置扫描程序。 br $>




点击开始,然后点击控制面板。如果适用,请单击左栏中的经典视图。



双击扫描仪和照相机。



右键单击相机或扫描仪。点击属性。



点击活动标签。



点击相机连接 事件下拉菜单。



点击操作标题下的启动此程序。



点击启动此程序右侧的下拉菜单中的Microsoft扫描仪和照相机向导。



点击应用,然后点击OK。

Hi I work Silverlight 5 and use the following code for scanning, it works fine on win 8 but on windows xp it dose not work,
can anyone assistance me?

private void Button_Click_1(object sender, RoutedEventArgs e)
      {
          try
          {
              using (dynamic CommonDialog = AutomationFactory.CreateObject("WIA.CommonDialog"))
              {
                  dynamic imageFile = CommonDialog.ShowAcquireImage();
                  if (imageFile != null)
                  {
                      if (!Directory.Exists("D:\\ScanImage"))
                      {
                          Directory.CreateDirectory("D:\\ScanImage");
                      }
                      string filePath = string.Format("D:\\ScanImage\\{0}.jpg", Guid.NewGuid());
                      imageFile.SaveFile(filePath);
                  }
              }
          }
          catch (System.Runtime.InteropServices.COMException ex)
          {
              if (ex.ErrorCode == -2145320939)
              {
                  MessageBox.Show("Could not find an attached scanner.", "Scanner Error", MessageBoxButton.OK);
              }
              else
              {
                  MessageBox.Show(ex.Message, "Scanner Error", MessageBoxButton.OK);
              }
          }

      }

解决方案

Check if the scanner library is registered on the Windows XP machine.
Also ensure the right version of Silverlight is available on that machine.


• Change the reg key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Silverlight debugging value to 1


If silverlight is enabled or registry is set to 1 thn may be you have not configured your scanner in windows xp since it is default in windows 8.


Click "Start," then "Control Panel." Click "Classic View" in the left column if applicable.

Double-click "Scanners and Cameras."

Right-click your camera or scanner. Click "Properties."

Click the "Events" tab.

Click "Camera connected" in the "Event" drop-down menu.

Click "Start this program" under the "Actions" header.

Click "Microsoft Scanner and Camera Wizard" in the drop-down menu to the right of "Start this program."

Click "Apply," then "OK.


这篇关于如何从silverlight访问扫描仪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆