如何知道应用程序通过哪个事件启动? [英] How to Know through which event an application get started?

查看:105
本文介绍了如何知道应用程序通过哪个事件启动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,亲爱的朋友

我已经在C#Visual Basic 2008中创建了一个应用程序,该应用程序在系统启动时启动,然后我要询问是否为假应用程序关闭的情况..但是我想在桌面上使用图标启动应用程序,以便用户可以更改在不关闭应用程序的情况下运行应用程序所需的条件........这意味着我想知道用户何时使用桌面或开始菜单上的图标启动应用程序.

请帮我...

Hello My Dear Friends

I have created an application in C# visual basic 2008, which is starting when System Starts then i am asking for a condition if it is false application get close ..but i want to start my application with an icon on desktop so that user can change the condition required to run application without get closed ........ it means i want to know when user start my application with icon on desktop or start menu.

please Help me ...

推荐答案

最简单的方法是给它一个参数或自变量.
如果您签入Main Method(控制台类型的应用程序),或对Winforms使用Environment.GetCommandLineArgs(),则可以读取传递给应用程序的参数.

将系统启动版本设置为具有诸如"/Automatic"或类似参数的参数,您就可以非常容易地检测到启动模式.
Easiest way is give it a parameter, or argument.
If you check in your Main Method (console type apps), or use Environment.GetCommandLineArgs() for winforms, you can read the parameters passed to the application.

Set up the System Startup version to have an parameter such as "/Automatic" or similar, and you can detect the startup mode pretty easily.


您可以使用我易于使用的命令行解析库:基于枚举的命令行实用程序 [
You can use my easy-to-use command line parsing library: Enumeration-based Command Line Utility[^].

It is complete with full source code and detailed explanation. Two previous articles explaining the techniques are referenced, as well as one alternative (more complex) command line utility.

—SA


这篇关于如何知道应用程序通过哪个事件启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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