Suppose I have an executable file, and when it is running, I want to know how it was launched. That is, I would like to know if it is launched by a shortcut or directly. Wherein:
string test = Environment.GetCommandLineArgs()[0];
I can get the path to the executable, but this is always the same, even if it starts with a shortcut.
Lets say that my executable file is named c: \ text.exe, and I run it directly, and then test = 'c: \ test.exe' If I create a shortcut, that is c: \ shortcut.lnk (for the purpose c: \ test.exe), I want the test to be "c: \ shortcut.exe", but this is "c: \ test.exe"
I strongly suspect that this is impossible, because the OS processes part of the shortcut, and the executable never sees the difference, but maybe someone has a creative idea?
source
share