How I can get printer name from device and printers IShellFolder?

血红的双手。 提交于 2019-12-04 18:46:12

Find the answer by myself.

To enumerate printers in IShellFolder we must use IShellFolder.ParseDisplayName method, not EnumObjects, and send printer name from PrinterSettings.IntalledPrinters (such as "\ServerName\PrinterName" for network printers) to IShellFolder.ParseDisplayName param pszDisplayName, IShellFolder "Devices and printers" work with this well.

So, after this we can enumerate real printer names ("\ServerName\PrinterName"), printer display names ("PrinterName on ServerName" as printers listed in "Devices and printers") and printer icons.

I will post full code here for father search after some edits.

In the loop you can use printersShellFolder.GetUIObjectOf for IID_IDataObject on current rgelt[0] and call IDataObject::GetData with "PrinterFriendlyName" as clipboard format to get the real printer name (encoded in STGMEDIUM).

You can use printersShellFolder.GetUIObjectOf for IID_IQueryInfo on the current pidl to get the printer status too.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!