Try another Main function:
static void Main( )
{
string [] all_args = Environment.GetCommandLineArgs( );
string args = all_args.ElementAtOrDefault(1);
if( args == "correct_key")
. . .
}
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello
What i am trying to do is: (windows forms)
a program starts another program using Process.Start("second_program.exe","login_key");
when second_program starts it reads the startup parameter and if the login_key is correct it starts the form, if not it shuts down
i dont know how to tell this better. Code will explain better:
PROGRAM1
Process.Start("second_program","correct_key");
SECOND_PROGRAM
static void Main(string args)
{
if(args== "correct_key")
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
MessageBox.Show("Successfully logged in!", "-", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Error", "-", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(-1);
}
}
Try another Main function:
static void Main( )
{
string [] all_args = Environment.GetCommandLineArgs( );
string args = all_args.ElementAtOrDefault(1);
if( args == "correct_key")
. . .
}