Reputation: 36
I have two different executables, one is a login and the other is the main application.
Now, i want to make it only possible to open the login, but not the main program. Right now you can open the main app just by clicking on it.
The login app creates a small txt file with some information, and the main program then starts and deletes the file.
Is there a way to make the main program only start if this one file exists? So that nobody can start the main app without the login first.
So, when you login, the app checks with a mysql database if your account exists. Then this runs:
string übergabeparameter = Convert.ToString(typ);
string filename = (@"C:\Users\viuser\Desktop\test\dat.exe");
var proc = System.Diagnostics.Process.Start(filename, übergabeparameter);
using (System.IO.StreamWriter sw = System.IO.File.CreateText("fluff.txt"))
{
sw.Write(benutzername + System.Environment.NewLine + typ);
}
Close();
Then dat.exe starts, and runs this:
bürgerlichername = File.ReadLines("fluff.txt").First();
string line = File.ReadLines("fluff.txt").Skip(1).Take(1).First();
if (line == "1")
{
typ = "Trainer";
}
else
{
typ = "Lehrling";
};
System.IO.File.Delete("fluff.txt");
I created both apps in visual studio with wpf and c#.
Upvotes: 0
Views: 280
Reputation: 3993
In the startup code for the main app check for the file. If the file don't exist you can message the user to launch the correct exe (login). I would also have the login add some kind of hash code so the main program knows the login is legit to protect against faking the login or maybe a an old txt file that didn't get deleted after a previous login (main org might have crashed or other abend before deleting file.)
Upvotes: 1