views:

190

answers:

2

Hello world!

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).

+1  A: 

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.

ho1
Much simpler, then you don't have to change your exe when you add a new shortcut to the system.
Greg B
A: 

ho1, thanks for the suggestion, but that's not really what I want. I agree it's easy for me to do it. It's not, however, the "easiest" way for the user. They would have to right click on the shortcut and enter the parameter after the target path. Not really user friendly.

I want them to make shortcuts themselves and then maybe enter the parameter (the first time they run the shortcut) which would be saved somewhere (maybe even as a target path parameter in the shortcut).

There's got to be a way! ;)

okkko