Getting the starting shortcut in c#

Posted by Flores on Stack Overflow See other posts from Stack Overflow or by Flores
Published on 2010-03-25T08:21:59Z Indexed on 2010/03/25 8:23 UTC
Read the original article Hit count: 368

Filed under:
|
|

Lets say that I have an executable and when it is started I want to know how it's started. I.e. I would like to know if it is started with a shortcut or directly. With this:

string test = Environment.GetCommandLineArgs()[0];

I can get the path of the executable, but this is always the same, even if it's started by a shortcut.

Lets say my executable is named c:\text.exe and I start it directly, then test = 'c:\test.exe' If I create a shortcut i.e. c:\shortcut.lnk (with target c:\test.exe) I want test to be 'c:\shortcut.exe' but it is 'c:\test.exe'

I strongly suspect this to be impossible because the OS handles the shortcut part and the executable never can see the difference, but maybe someone has a creative idea?

© Stack Overflow or respective owner

Related posts about c#

Related posts about shortcut