請問,如何知道共安妝了几個打印機呢,

ylm0101 2003-10-20 08:48:29
請問,如何知道共安妝了几個打印機呢,
也就是把所有的打印機列出來,謝謝
...全文
31 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
haoliqi 2003-10-20
  • 打赏
  • 举报
回复
在页上来个DropDownlist1
Page_Load加入
foreach(string iprt in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
this.DropDownList1.Items.Add(iprt);
DropDownlist1中会枚举出本地打印机!
CMIC 2003-10-20
  • 打赏
  • 举报
回复
如何在webform中获得当前机器的可用打印机列表(包括本地的和网络的)?
http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=32007
bpy 2003-10-20
  • 打赏
  • 举报
回复
xuexi
rgbcn 2003-10-20
  • 打赏
  • 举报
回复
get printer of lan net

Use the DirectoryServices and the native ADSI interfaces to control printqueues and jobs.

Here is a sample to get you started:

using System;
using System.DirectoryServices;
using System.Runtime.InteropServices;
using activeds; // Import activeds.tlb interop assembly
/********************************************************************************
// needs a reference to the interop assembly generated by tlbimp.exe
// Compile with csc /r:activeds.dll adprinter.cs
********************************************************************************/

class Tester {
// Printer status flags - see SDK docs for status values (IADsPrintQueueOperations)
[Flags]
enum PrinterStatus {
Paused = 1,
DeletePending = 2,
Error = 3,
PaperJam = 4,
PaperOut = 5
}
public static void Main() {
DirectoryEntry printer = new DirectoryEntry("WinNT://servername/printqueuename", null, null, AuthenticationTypes.ServerBind);
Console.WriteLine(printer.Path);
PropertyCollection pcoll = printer.Properties;
try
{
foreach(string sc in pcoll.PropertyNames) {
Console.WriteLine(sc + ":\t" + (pcoll[sc])[0].ToString());
} Console.WriteLine("---------------------------------");
}
catch(COMException ex)
{
Console.WriteLine(ex.Message);
}
// Use the PrintqueueOperations interface to contol the printer Queue
IADsPrintQueueOperations po = printer.NativeObject as IADsPrintQueueOperations ;
if(po != null) {
if(po.Status == (int)PrinterStatus.Paused) // If paused resume else pause printer
po.Resume();
else
po.Pause();
// Use the IADsPrintJob to control individual printjobs
foreach(IADsPrintJob pj in po.PrintJobs()) {
Console.WriteLine("{0} - {1}", pj.Description, pj.Name);
IADsPrintJobOperations pjo = pj as IADsPrintJobOperations;
Console.WriteLine(pjo.Name);
// Use IADsPrintJob.Name as arg. to remove the job from the queue
po.PrintJobs().Remove(pj.Name);
}
} printer.Dispose();
}
}

rgbcn 2003-10-20
  • 打赏
  • 举报
回复
get the 网络打印机名 from your registry:...

通常情况下,请不要创建 PrinterSettings 的实例,而是改用 PrintDocument.PrinterSettings 来设置打印机的设置。
Public Sub Printing(printer As String)
Try
streamToPrint = New StreamReader(filePath)
Try
printFont = New Font("Arial", 10)
Dim pd As New PrintDocument()
AddHandler pd.PrintPage, AddressOf pd_PrintPage
' Specify the printer to use.
pd.PrinterSettings.PrinterName = printer

If pd.PrinterSettings.IsValid then
pd.Print()
Else
MessageBox.Show("Printer is invalid.")
End If
Finally
streamToPrint.Close()
End Try
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
rgbcn 2003-10-20
  • 打赏
  • 举报
回复
是列出同一台机器上的,局域网内的

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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