我可以通过 .Net 获取与已安装打印机关联的图标吗? [英] Can I get the icon associated with an installed printer through .Net?

查看:18
本文介绍了我可以通过 .Net 获取与已安装打印机关联的图标吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何使用 .Net 获取机器上所有已安装打印机的列表:

I know how to get the list of all of the installed printers on a machine with .Net:

foreach (String printer in PrinterSettings.InstalledPrinters)
{        
    Console.WriteLine(printer.ToString());
}
Console.ReadLine();

InstalledPrinters 只是一个字符串列表.有什么方法可以获取已安装的打印机对象,其中包含我通常会在 Windows 资源管理器中的设备和打印机"下看到的名称和图标图像?

InstalledPrinters is just a list of strings though. Is there any way to get the installed printer objects that contain both the name and the icon image that I would ordinarily see under "Devices and Printers" in the Windows Explorer?

推荐答案

图标通常嵌入到任一dll文件或主EXE中,查看System.Drawing.Icon静态方法,以下链接为WinForms,它与 WPF 略有不同,因为您必须从提取的图标流中创建一个 ImageSource.

The icon is normally embedded into either one of the dll files or the main EXE, look at the System.Drawing.Icon static methods, the link below is for WinForms, its slightly different with WPF as you have to create an ImageSource from the extracted icon stream.

如何:在 Windows 窗体中提取与文件关联的图标

这篇关于我可以通过 .Net 获取与已安装打印机关联的图标吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆