为什么shellexecuteex用动词“ print”考虑应用程序的LNK文件设置?

发布于 2025-01-28 00:02:55 字数 1850 浏览 3 评论 0原文

上下文

我通过将文件路径转发到shellexecuteex和动词print来通过Windows应用程序打印PDF文件。为该动词安装并注册Adobe Reader。默认情况下,读者在开始菜单中创建一个LNK快捷方式文件:

c:\ programData \ Microsoft \ Windows \ Windows \ Start Menu \ Program \ Adob​​e Acrobat dc.lnk

隐藏Windows

默认情况下,Reader在打印PDF时显示GUI窗口。一些客户不想要该窗口,只是尝试通过使用Windows Explorer属性更改LNK文件内容来“隐藏”它,以至少默认情况下最小化Windows。那个客户不知道这是否有效,一个人只是尝试了。

令我惊讶的是,这可以使用,更改LNK文件的最小化与非最小化/默认设置,使读取器窗口可见或最小化。

注册表没有任何更改,

我已经搜索了注册表,以了解有关print动词的更改设置,但找不到任何动词。新设置似乎确实仅存储在lnk文件中:

​几乎就像预期的那样,我从来没有使用LNK文件遇到过任何Shell动词注册。

"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /p /h "%1"

但是,动词print的所有调用似乎都识别出设置,要么手动使用Windows Explorer中某些PDF的上下文菜单,要么在Shell上执行事物:

powershell -Command "Start-Process -Verb print '\\?\C:\[...].pdf'"

为什么很重要?

Adobe Reader提供命令行参数/h也可以最大程度地减少自身,但是使用它根本没有完全隐藏窗口。取而代之的是,显示了一秒钟左右的窗口,然后最小化,例如Adobe像Adobe一样。 OTOH,随着更改的lnk文件的变化,情况有所不同:实际上,窗口实际上是完全显示的,或者仅显示了窗口标题(例如窗口标题)或少于一秒钟的文物。

实际上,似乎是Adobe加载后独立执行某些操作与Windows本身创建最小化窗口之间的区别。

此外,如果可能的话,我想避免客户需要更改自己的LNK。该更改的问题在于,它不仅与print动词绑定,而是每当打开Adobe读取器时。有时,客户确实需要查看自己的PDF,而不是仅自动打印。

那么,这是如何工作的?

Windows本身是使用该LNK文件的设置,还是Adobe Reader实现的?

使用Procmon,我找不到有关Adobe读取器本身读取LNK文件的任何提示。同样,我找不到有关shell动词,shellexecuteex等的主题中记录的这种行为。这对我来说是完全出乎意料的,因为lnk文件是理论上的一些任意文件,这可能不存在所有人都可以称为一个喜欢的人,即使是其中的多个也可能存在于理论上,从理论上讲,启动了某些软件包或具有不同参数等的同一应用程序等的不同应用。

感谢您的任何见解。

Context

I have a Windows app printing PDF files by forwarding the file paths to ShellExecuteEx and the verb print. Adobe Reader is installed and registered for that verb. Reader by default creates a LNK shortcut file in the start menu:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Adobe Acrobat DC.lnk

Hide windows

By default, reader shows a GUI window when printing a PDF. Some customer doesn't want that window and simply tried to "hide" it by changing the LNK file content using Windows Explorer properties to at least minimize the windows by default. That customer didn't know if that works or not, one simply tried.

LNK file settings

To my surprise this worked, changing the minimize vs. non-minimize/default setting of the LNK file made the reader windows being visible or minimized.

No changes in registry

I've searched the registry for changed settings regarding the print verb, but couldn't find any. The new setting really seemed to be only stored within the LNK file:

DIFF of LNK file with vs. without minimized set

The registry contained references to the actual EXE only, not the LNK file. Pretty much like expected, I've never came across any shell verb registration using LNK files at all.

"C:\Program Files\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /p /h "%1"

Though, all invocations of the verb print seemed to recognize that setting, either manually using the context menu of some PDF in Windows Explorer or executing things on the shell:

powershell -Command "Start-Process -Verb print '\\?\C:\[...].pdf'"

Why is that important?

Adobe Reader provides the command line argument /h to minimize itself as well, but using that doesn't fully hide a window at all. Instead, a window is shown for a second or so and afterwards minimized, e.g. like Adobe is doing that itself. OTOH, with the changed LNK file things are different: Either really now window is shown at all or only some artifacts like the window title or alike for less than a second.

It really seems that the difference is between Adobe doing something on it own after it has loaded and stuff vs. Windows itself creating the minimized window already.

Additionally, if possible at all I would like to avoid customers needing to change the LNK file themself. The problem with that change is that it's not tied to the print verb only, but whenever Adobe Reader gets opened. And sometimes customers really need to have a look at PDFs themself instead of automatic printing only.

So, how does that work?

Is Windows itself using the setting of that LNK file or is this something implemented by Adobe Reader?

Using ProcMon, I couldn't find any hint about that Adobe Reader itself reads the LNK file. As well, I couldn't find this behaviour documented in the topics about shell verbs, ShellExecuteEx etc. It's totally unexpected to me, as the LNK file is some arbitrary file in theory, which might not exist at all, can be named as one likes, even multiple of those could exist in theory starting different apps of some package or the same app with different arguments etc.

Thanks for any insights.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文