如何获取.net中的快捷方式路径(而不是目标路径)?

发布于 2024-09-03 20:47:23 字数 173 浏览 8 评论 0原文

我有一个用 vb.net 编写的 .exe 应用程序。当我创建应用程序的快捷方式时,比如说在桌面上(或其他任何地方),然后单击它们,我想以编程方式获取该快捷方式的路径,即。 C:/Users/xxx/Desktop/shortcut.lnk。

我想要这个,这样我就可以存储成对的快捷方式:(程序+不同的cmd参数)。

I have an .exe application written in vb.net. When I make shortcuts to the application, say on desktop (or anywhere else) and then click on them I want to programatically get the path to that shortcut, ie. C:/Users/xxx/Desktop/shortcut.lnk.

I want this so I can store the pairs shortcuts : (program + different cmd args).

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

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

发布评论

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

评论(1

垂暮老矣 2024-09-10 20:47:23

您的桌面不会是父进程,因为它不是一个进程,我假设资源管理器或其他东西如果是从快捷方式启动的,那么它就是父进程。

获得所需内容的最简单方法是更改​​快捷方式,以便在应用程序启动时将某些参数发送到应用程序。例如,桌面上的快捷方式可以发送字符串“desktop”。然后你可以将它作为普通的命令行参数。

如果您将 Main 函数声明为:

Public Shared Sub Main(ByVal args As String())

那么它将显示为 args 参数中的字符串之一。

Your desktop wouldn't be the parent process since it's not a process, I assume explorer or something would be if it's started from a shortcut.

The easiest way to get what you want would be to change the shortcuts to send in some parameter to your app when it starts it. So for example, the shortcut on the desktop could send in the string "desktop". Then you could just pick it up as a normal command line parameter.

If you've declared a Main function as:

Public Shared Sub Main(ByVal args As String())

Then it would appear as one of the strings in the args parameter.

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