获得在C#中的快捷方式启动 [英] Getting the starting shortcut in c#

查看:365
本文介绍了获得在C#中的快捷方式启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我有一个可执行文件,当它开始我想知道它是如何开始的。即我想如果是开始一个快捷方式,或直接就知道了。
有了这个:

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.

比方说我的可执行文件被命名为c:\text.exe,我开始直接,然后进行测试=C:\test.exe'
。如果我创建一个快捷方式即c:\shortcut.lnk(与目标C:\test.exe)我想测试是C:\shortcut.exe',但它是C:\test .EXE

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?

推荐答案

这将不是一般的工作,但如果你正在创建快捷方式,你可以添加一个命令行参数来识别它

This won't work in general, but if you are creating the shortcut, you could add a command line parameter to identify it.

这篇关于获得在C#中的快捷方式启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆