【急、救助 200分】关与Pos for .net sdk PosExplorer.GetDevices();找不到打印机的问题

让爱延续 2010-12-26 12:17:35

我的测试代码如下:


private PosExplorer explorer;

private DeviceCollection deviceCollection;

private PosPrinter printer;


// 查找Pos打印机列表
private void btnSearchPosPrinter_Click(object sender, EventArgs e)
{


// 获取类型为 PosPrinter 的设备列表
this.deviceCollection = this.explorer.GetDevices(DeviceType.PosPrinter);
this.LvPosCollection.Items.Clear(); // 清空显示列表

if (deviceCollection != null && deviceCollection.Count > 0)
{
List<ListViewItem> itemList = new List<ListViewItem>();
ListViewItem itemTemp = null;
foreach (DeviceInfo info in this.deviceCollection)
{
itemTemp = new ListViewItem(info.Type);
if (info.LogicalNames.GetLength(0) > 0)
{
itemTemp.SubItems.Add(info.LogicalNames[0]);
}
else
{
itemTemp.SubItems.Add("未命名");
}
itemTemp.SubItems.Add(info.Description);
itemList.Add(itemTemp);
}
this.LvPosCollection.Items.AddRange(itemList.ToArray());
}
else
{
MessageBox.Show("没有找到打印机", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}



在当前的代码中 this.deviceCollection 只有一个 打印机 其描述为 Simulated service object for Pos Printer,即一个模拟器、每一台电脑上都有的。 但是找不到真正的打印机设备,这是为何啊?

现在可以确定 已经有一个打印机已经被正确安装了, 且可以正常打印, 该打印机用的是网口配置的。

很着急的啊, 希望大侠帮忙的。。。

...全文
194 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
qthl004 2012-08-07
  • 打赏
  • 举报
回复
楼主说的是这个软件么??


Bytescout Spreadsheet SDK for .NET是一款性价比较高的表格控件产品,无需Excel而只使用本地的.NET库来写,读,修改,计算电子表格。

Bytescout Spreadsheet SDK for .NET产品特征:

在系统中使用Bytescout Spreadsheet SDK for .NET 不需要额外安装Excel或任何其它任何电子表格软件;
在您开发的产品或者程序中使用Bytescout Spreadsheet SDK for .NET不需要支付任何分发费用(一次购买,完全免费分发);
Bytescout官方提供12个月免费升级服务和免费邮件技术支持(您的问题将在两个工作日内解决) ,如果要延长12个月的免费升级仅仅需要支付您购买产品的30%的价格即可得到;
Bytescout Spreadsheet SDK for .NET100%纯.NET托管代码创建,支持.NET1.10,.NET2.00或更高版本;
支持XLS, HTML, TXT, CSV, XML写入;
支持CSV, XLS(Office97-2003), XLSX (Office 2007)和ODS (Open Office Calc)读取;
支持公式计算; (standard functions, add-in formulas like XIRR)
支持读取XLS Excel文档;
Bytescout Spreadsheet SDK for .NET可以被用于Visual C#, Visual Basic.NET和ASP.NET中;
支持单元格,列,行,工作表;
支持Unicode编码;
支持单元格格式;(字体、颜色,样式风格等)
可以修改现有Excel文档;
可以将XLS导出为CSV, TXT, HTML和XML;
支持XLS文档文件的读取;
Bytescout Spreadsheet SDK for .NET产品提供完整的示例,简化您的开发。

Bytescout Spreadsheet SDK for.NET
http://www.fanganwang.com/Product-detail-item-1213.html下载地址
让爱延续 2010-12-26
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 wuyq11 的回复:]
<PointOfServiceConfig Version="1.0">

<ServiceObject Name="Microsoft LineDisplay Simulator" Type="LineDisplay">
<Device HardwarePath="" Enabled="yes" PnP="no" Default="no">
<LogicalName Name="my_device" />
</Device>
</ServiceObject>
</PointOfServiceConfig>

[/Quote]

还有 这个是怎么回事啊?配置文件吗? 这个和 查找PosPrinter有关吗? 谢谢啊!
让爱延续 2010-12-26
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 wuyq11 的回复:]
var deviceCollection = posExplorer.GetDevices();
foreach (DeviceInfo dInfo in deviceCollection)
{
}看看
PosExplorer posExplorer = new PosExplorer();
DeviceInfo deviceInfo = null;
deviceInfo = po……
[/Quote]
我现在的代码:


// 查找Pos打印机列表
private void btnSearchPosPrinter_Click(object sender, EventArgs e)
{


// 获取类型为 PosPrinter 的设备列表
this.deviceCollection = this.explorer.GetDevices();


this.LvPosCollection.Items.Clear(); // 清空显示列表

if (deviceCollection != null && deviceCollection.Count > 0)
{
int num = 0;

foreach (DeviceInfo info in this.deviceCollection)
{
if (info.Type == DeviceType.PosPrinter)
{
num++;
}
}

MessageBox.Show("找到" + num.ToString() + "个Pos打印机");

}
}

只能找到一个打印机的。

还有 这个是怎么回事啊?配置文件吗? 这个和 查找PosPrinter有关吗? 谢谢啊!
wuyq11 2010-12-26
  • 打赏
  • 举报
回复
var deviceCollection = posExplorer.GetDevices();
foreach (DeviceInfo dInfo in deviceCollection)
{
}看看
PosExplorer posExplorer = new PosExplorer();
DeviceInfo deviceInfo = null;
deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo);

http://social.msdn.microsoft.com/Forums/en/posfordotnet/thread/e691ac68-39b7-4407-9e06-94f13b833c88

让爱延续 2010-12-26
  • 打赏
  • 举报
回复
问题解决立即 结贴。。。
让爱延续 2010-12-26
  • 打赏
  • 举报
回复
有知道是怎么回事的吗? 为什么找不到真正的打印机呢??

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧