【问题标题】:Perform an action when a program starts程序启动时执行操作
【发布时间】:2013-01-20 20:06:31
【问题描述】:

假设我想在启动特定 EXE 时运行批处理文件。 Win32 API 中是否有任何挂钩?

我将 VCL 与 Delphi 一起使用,但有关这方面的一般信息也会很好。 该程序应该在后台运行,当用户启动应用程序时,程序会检测到这一点,检查应用程序是否符合条件,如果符合则运行相关的批处理文件。

【问题讨论】:

  • 据我在快速网络搜索中找到的,您无法收到已启动程序的通知。您可以执行轮询,但您可能为时已晚。如果您更好地解释问题本身,则可能会建议更简单的解决方案。例如,您能否创建一个用户启动的自定义可执行文件或批处理文件,以便您要运行的代码预先运行,然后启动用户希望启动的应用程序?
  • @CodeCaster 是的,确实可以。
  • 您可以查看AppInit_DLLs 注册表值以在进程加载时加载DLL。

标签: windows winapi hook vcl


【解决方案1】:

你试过用Delphi的Create Process Function吗?

这是一个小链接,它可以指导您完成该过程:

http://snipplr.com/view/59064/using-createprocess-to-execute-programs/

【讨论】:

  • 我需要的是基本上检测进程何时启动的东西。我已经用其他信息更新了这个问题,希望能消除任何困惑。 The program is supposed to run in the background, and, when the user starts an application, the program detects this, checks whether the application matches the criteria and runs the associated batch file if so.
  • 好吧,就像 TSR 程序一样,我仍然相信使用创建进程的线程可以处理它。如果我得到任何其他解决方案,我会发布它。
猜你喜欢
  • 1970-01-01
  • 2023-02-24
  • 1970-01-01
  • 2013-02-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-22
  • 1970-01-01
相关资源
最近更新 更多