如何获取.net中的快捷方式路径(而不是目标路径)?
我有一个用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的桌面不会是父进程,因为它不是一个进程,我假设资源管理器或其他东西如果是从快捷方式启动的,那么它就是父进程。
获得所需内容的最简单方法是更改快捷方式,以便在应用程序启动时将某些参数发送到应用程序。例如,桌面上的快捷方式可以发送字符串“desktop”。然后你可以将它作为普通的命令行参数。
如果您将
Main
函数声明为:那么它将显示为
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:Then it would appear as one of the strings in the
args
parameter.