gpt4 book ai didi

c - ShellExecute 在哪里找到 exe 文件

转载 作者:太空宇宙 更新时间:2023-11-04 00:47:43 25 4
gpt4 key购买 nike

我正在用纯 C 编写一个程序,使用 win32 api。

我需要知道已注册程序的完整路径。

例如如果我写

ShellExecute(0,0,"chrome",0,0,SW_SHOW)

Chrome 浏览器启动。如何从 "chrome" 获取 "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" 作为 ShellExecute 是吗?

最佳答案

在这种情况下,Chrome 已经在 App Paths 注册表部分注册了自己。有关 MSDN 的更多详细信息:https://msdn.microsoft.com/en-us/library/windows/desktop/ee872121.aspx

Finding an Application Executable

When the ShellExecuteEx function is called with the name of an executable file in its lpFile parameter, there are several places where the function looks for the file. We recommend registering your application in the App Paths registry subkey. Doing so avoids the need for applications to modify the system PATH environment variable.

The file is sought in the following locations:

  • The current working directory.
  • The Windows directory only (no subdirectories are searched).
  • The Windows\System32 directory.
  • Directories listed in the PATH environment variable.
  • Recommended: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths

documentation告诉您 shell 如何搜索,您可以复制该搜索。

关于c - ShellExecute 在哪里找到 exe 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31135598/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com