打印机属性silverlight com互操作和浏览器外
我需要访问打印机,以了解打印机是否处于活动状态并有纸张 我使用silverlight 4开箱即用,信任度高 在这一点上,我有:打印机属性silverlight com互操作和浏览器外,silverlight,printing,com-interop,Silverlight,Printing,Com Interop,我需要访问打印机,以了解打印机是否处于活动状态并有纸张 我使用silverlight 4开箱即用,信任度高 在这一点上,我有: string cFileName = "temp.txt"; string cAction = "print"; using (dynamic fso = AutomationFactory.CreateObject(@"Scripting.FileSystemObject")) { dynamic file = fso.C
string cFileName = "temp.txt";
string cAction = "print";
using (dynamic fso = AutomationFactory.CreateObject(@"Scripting.FileSystemObject"))
{
dynamic file = fso.CreateTextFile(cFileName, true);
file.WriteLine("First line text");
file.WriteLine("second line text");
file.Close();
}
//Print
dynamic shell = AutomationFactory.CreateObject("Shell.Application");
shell.ShellExecute(cFileName, "", "", cAction, 1);
我正在使用一个临时文件txt来创建我的打印页面
顺便问一下,可以直接向打印机发送字符串或类似的内容吗
使用该代码,我无法查看打印机是否处于活动状态或操作是否成功完成
我看到我可以使用System.Drawing.Printing在C#中使用代码>或使用系统管理但是我认为silverlight是不可能的
有什么建议吗
--编辑--
我找到了解决办法。
现在我正在使用Win32_Printer类从打印机获取信息
string name;
int printerStatus;
int detectedErrorState;
using (dynamic locatorService = AutomationFactory.CreateObject("WbemScripting.SWbemLocator"))
{
locatorService.Security_.ImpersonationLevel = 3;
locatorService.Security_.AuthenticationLevel = 4;
var wmiService = locatorService.ConnectServer(".", @"root\cimv2");
using (dynamic result = wmiService.ExecQuery("Select * from Win32_Printer where Default = True"))
{
name = result.ItemIndex(0).Name;
printerStatus = result.ItemIndex(0).PrinterStatus;
detectedErrorState = result.ItemIndex(0).DetectedErrorState;
}
}
链接:
现在我尝试在没有temp file.txt的情况下打印
我想直接从代码打印到打印机
如果有人有建议,请告诉我