如何在Web浏览器中访问扫描仪 [英] How to access scanner in web browser
问题描述
我已经使用vs2010和silverlight 5在网络浏览器中访问扫描仪。当我在iis7上托管应用程序时,我可以访问Mozilla中的扫描程序,但不能访问Internet Explorer。为什么IE浏览器不支持在网络浏览器中访问扫描仪?
我做了更改,
服务器端
•使用证书签署xap。
客户端
•将证书安装到受信任的发布者
•更改注册表项HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Silverlight \AllowElevatedTrustAppsInBrowser改为1
我的代码是,
I have used vs2010 and silverlight 5 to access scanner in web browser. When i host the application on iis7, i can able to access scanner in Mozilla but does not in internet explorer. why the IE browser does not support to access scanner in web browser?
I made changes in,
Server side
• Sign the xap using certificate.
Client side
• Install the cert into "trusted publishers"
• Change the reg key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Silverlight \AllowElevatedTrustAppsInBrowser" to 1
My code is,
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);
}
}
提前致谢
Thanks in advance
推荐答案
也许这里的例子可以帮助你:
http://blog.yezhucn.com/wiaaut/ showacquireimage.htm [ ^ ]
祝你好运!
Maybe the examples here can help you out:
http://blog.yezhucn.com/wiaaut/showacquireimage.htm[^]
Good luck!
Sugu,
要在IE中工作,只需在 InBrowserSettings.xml中更改ElevatedPermissions =必需
代码
Sugu,
To work in IE, Just change ElevatedPermissions="Required" in InBrowserSettings.xml
code
<InBrowserSettings>
<InBrowserSettings.SecuritySettings>
<SecuritySettings ElevatedPermissions="Required" />
<!--<SecuritySettings ElevatedPermissions="NotRequired" /> This is default-->
</InBrowserSettings.SecuritySettings>
</InBrowserSettings>
这篇关于如何在Web浏览器中访问扫描仪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!