已安装打印机的文件夹位置在哪里? [英] What is the folder location of installed printers?

查看:275
本文介绍了已安装打印机的文件夹位置在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取已安装打印机的图标.从我可以搜索的内容中,一种方法是检索.dll或.exe的图标,并将其作为打印机的图标.但是,很容易找到通过GUI安装的打印机:

I would like to retrieve icon of the installed printers. From what I could search, one of the approach is to retrieve the icon of the .dll or .exe and have it be the icon of the printer. However, it's easy to find printer installed through GUI at:

控制面板\硬件和声音\设备和打印机

Control Panel\Hardware and Sound\Devices and Printers

但是,此列表上的硬盘驱动器上是否有物理位置?这是即时创建的吗?

But, is there a physical location on hard drive to this list ? Is this created on the fly ?

推荐答案

没有包含打印机列表的物理磁盘文件夹.

There is no physical disk folder that contains a list of printers.

如果您在外壳名称空间中具有打印机的PIDL,则可以使用SHGetFileInfo轻松获得其图标.获得PIDL有点困难,但并非不可能.

If you have the PIDL for the printer in the shell namespace you can easily get its icon using SHGetFileInfo. Getting the PIDL is a little harder but not impossible.

我过去使用枚举虚拟打印机文件夹(CSIDL_PRINTERS)的功能来完成此操作,并将其中的每个项目的名称与我要查找的打印机的名称进行比较.找到匹配的名称后,您将获得PIDL,然后可以获取图标.

I have done this in the past with a function that enumerates the virtual printer folder (CSIDL_PRINTERS), and compares the name of each item within it against the name of the printer I am looking for. When you find a matching name you have the PIDL, and you can then get the icon.

例如(此代码当然并不完整,您需要对其进行充实):

For example (this code is not complete of course, you will need to flesh it out):

SHGetFolderLocation(hwnd, CSIDL_PRINTERS, 0, 0, &pidlPrinters);
SHBindToObject(0, pidlPrinters, 0, IID_IShellFolder, &psfPrinters);
psfPrinters->EnumObjects(hwnd, SHCONTF_NONFOLDERS, &pEnum);
while (pEnum->Next(1, &pidl, 0) == S_OK)
{
    psf->GetDisplayNameOf(pidl, SHGDN_NORMAL, &strName);
    StrRetToBuf(&strName, pidl, chBuf, _countof(chBuf));
    if (_wcsicmp(chBuf, pszPrinterToLookFor) == 0)
    {
        // printer matches
        // build full pidl (pidlPrinters + pidl)
        // pass to SHGetFileInfo with SHGFI_PIDL flag to get icon
    }
}

这篇关于已安装打印机的文件夹位置在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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