如何从 Windows 的开始菜单搜索中向我的程序传递一个字符串(如 ping)?

发布于 2024-09-19 18:13:53 字数 277 浏览 1 评论 0原文

当我的程序从开始菜单快捷方式启动时,我想向它发送一个字符串。我看到 ping 会执行此操作,因为我可以输入 ping [和域],它会弹出 cmd 窗口并执行 ping。不过,我认为这一定与我设置的工作方式不同,因为即使程序的快捷方式位于开始菜单中,但当我开始输入任何参数后搜索它时,它就会消失。然后 Windows 将启动一个 Windows 资源管理器窗口,尝试搜索我键入的内容。我必须做什么才能让它像 ping 程序一样注册?

另外,您认为它只是使用 string[] args 来捕获这个吗?

When my program is launched from the start menu shortcut I would like to send it a string. I see that ping does this because I can type in ping [and a domain] and it will pop the cmd window and do the ping. However I think this must be working differently than what I have setup because even though the shortcut to the program is in the start menu, it will disappear when I am searching for it as soon as I start typing any parameters. Then windows will just launch a windows explorer window attempting to search for what I typed. What must I do to get it to register like the ping program?

Also, do you think it is just using the string[] args to capture this?

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

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

发布评论

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

评论(1

我一向站在原地 2024-09-26 18:13:53

您是否尝试从 CMD 运行程序并从那里传递参数?类似于: <可执行文件的路径>...

是的,提供给程序的任何参数(如上所示)都可以在 main 方法的 args 变量中使用需要。

Did you try running your program from CMD and passing the parameters from there? Something like: <path to your executable> <arg1> <arg2>...<arg N>

And yes, any parameters that are given to the program (as shown above) are then available in the args variable that the main method takes.

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