Was program opened by a user or was it started from windows registry start up?
Is it somehow possible to detect whether program was started by a user or it was started 开发者_如何学编程automatically from registry at Windows start up?
The simplest way i know of would be to add a "--startup" or similar option to the command line for the startup shortcut (or the value in Run), and check for that in your app. If it's there, then the app is being run by Windows; otherwise, the user is running it.
My solution:
string[] args = Environment.GetCommandLineArgs();
if (args[1] == "-hide")
{
//Hide
}
精彩评论