最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
枚举打印机(winapi)
时间:2022-07-02 12:08:16 编辑:袖梨 来源:一聚教程网
using System;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
namespace Sample.GetPrinter
{
class App
{
static void Main(string[] args)
{
Console.WriteLine("请输入你想搜索类型的序号:");
Console.WriteLine("1. Default printer(only Win95,Win98,WinME) 2. Enumerates the locally installed printers; 3. Enumerates the list of printers to which the user has made previous connections; 4. Enumerates the printer identified by Name.; 5. Enumerates network printers and print servers in the computer's domain; 6. Enumerates printers that have the shared attribute; 7. Enumerates network printers in the computer's domain; ======================================================================");
int pt =0;
try
{
pt=Int32.Parse(Console.ReadLine());
}
catch(Exception e)
{
Console.WriteLine("错误信息: {0}",e.Message);
return;
}
PRINTER_ENUM printerKind = GetPrinterConType(pt);
PrinterSearcher p = new PrinterSearcher();
PrinterSearcher.PrinterInfo[] printers = p.Search(printerKind);
foreach(PrinterSearcher.PrinterInfo pi in printers)
{
Console.WriteLine("===================================== 打印机名: {0} 描叙:: {1} 注释: {2} ===================================== ",
pi.Name, pi.Description, pi.Comment);
}
}
static PRINTER_ENUM GetPrinterConType(int ins)
{
switch(ins)
{
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
namespace Sample.GetPrinter
{
class App
{
static void Main(string[] args)
{
Console.WriteLine("请输入你想搜索类型的序号:");
Console.WriteLine("1. Default printer(only Win95,Win98,WinME) 2. Enumerates the locally installed printers; 3. Enumerates the list of printers to which the user has made previous connections; 4. Enumerates the printer identified by Name.; 5. Enumerates network printers and print servers in the computer's domain; 6. Enumerates printers that have the shared attribute; 7. Enumerates network printers in the computer's domain; ======================================================================");
int pt =0;
try
{
pt=Int32.Parse(Console.ReadLine());
}
catch(Exception e)
{
Console.WriteLine("错误信息: {0}",e.Message);
return;
}
PRINTER_ENUM printerKind = GetPrinterConType(pt);
PrinterSearcher p = new PrinterSearcher();
PrinterSearcher.PrinterInfo[] printers = p.Search(printerKind);
foreach(PrinterSearcher.PrinterInfo pi in printers)
{
Console.WriteLine("===================================== 打印机名: {0} 描叙:: {1} 注释: {2} ===================================== ",
pi.Name, pi.Description, pi.Comment);
}
}
static PRINTER_ENUM GetPrinterConType(int ins)
{
switch(ins)
{
相关文章
- 《无限暖暖》天星之羽获得位置介绍 12-20
- 《流放之路2》重铸台解锁方法介绍 12-20
- 《无限暖暖》瞄准那个亮亮的成就怎么做 12-20
- 《无限暖暖》魔气怪终结者完成方法 12-20
- 《无限暖暖》曙光毛团获得位置介绍 12-20
- 《无限暖暖》日光果获得位置介绍 12-20