EXE文件右键菜单

发布于 2025-01-07 03:46:43 字数 225 浏览 6 评论 0原文

我想知道是否可以在 Delphi 中实现添加到 EXE 文件右键菜单中的一些项目,特别是尚未在任何地方注册或安装的 Windows 服务应用程序 EXE。菜单选项允许用户将 EXE 作为 Windows 服务安装/卸载。这可能吗?如果是这样,那又如何呢?如果仅兼容 Windows Vista+ 也没关系。

将有 2 个菜单项:

  • 安装(或卸载)
  • 开始(或停止)

I was wondering if it was possible in Delphi to implement some items added to the right-click menu of an EXE file, specifically a Windows Service Application EXE which has not yet been registered or installed anywhere. The menu options would allow user to install/uninstall the EXE as a windows service. Is this possible? If so, then how? It's OK if it's only compatible with Windows Vista+.

There would be 2 menu items:

  • Install (or Uninstall)
  • Start (or Stop)

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

兮子 2025-01-14 03:46:43

如果您指的是 Shell 上下文菜单(Windows 资源管理器中的右键单击窗口),则不能。您可以添加到将为所有 .exe 文件显示的菜单,但不能为单个文件添加。

您可以为所有可执行文件注册一个上下文菜单处理程序,然后过滤传递的文件名以查看是否需要处理它,但这意味着对于数百(或数千)个可执行文件中的每一个如果您的计算机上有大量可执行文件,那么您的过滤器将在右击您的应用程序的可能性很小的情况下运行。

一种可能的解决方法是将具有自定义扩展名的文件放入服务的文件夹中,并为该文件添加上下文菜单处理程序。右键单击该文件时,菜单项将简单地使用适当的命令行参数调用您的服务。

(当然,最好的解决方案是使用控制面板的服务小程序来管理您的服务,这是它专门设计的用途。)

If you're referring to the Shell Context Menu (the right-click window in Windows Explorer), you cannot. You can add to the menu that will be displayed for all .exe files, but not for an individual one.

You could register a context menu handler for all executables, and then filter the filename passed to see if you needed to handle it or not, but this would mean that for every one of the hundreds (or thousands) of executable files on your machine, your filter would run on the slim chance it was your application that was right-clicked.

A possible workaround would be to put a file with a custom extension in your service's folder, and add a context menu handler for that file instead. When that file is right-clicked, the menu items would simply call your service with the appropriate command-line parameters.

(Of course, the best solution is to use the Control Panel's Services applet to manage your service, which is what it's designed specifically do do.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文