【发布时间】:2018-04-14 01:56:14
【问题描述】:
我想为我的 Windows 窗体应用程序创建一个简单的一次性激活过程。所以,我基本上有两种形式,form1是激活窗口,form2是实际程序。我在下面给出的 form1 中创建了一个非常基本的激活程序
string mac = textBox1.Text;
string str1 = mac.Substring(4,1);
string str2 = mac.Substring(5,1);
string str3 = mac.Substring(7,1);
string str4 = mac.Substring(2, 1);
string pattern = str1 + str2 + str2 + str3 + str4;
if (textBox2.Text == pattern)
{
MessageBox.Show("Program activated!!!");
Form2 n = new Form2();
n.Show();
this.Hide();
}
else { MessageBox.Show("Wrong key"); }
现在,问题是每次我加载我的程序时,它总是加载 form1,即使之前有人成功输入了密钥(即pattern)。我如何存储该信息,以便如果有人输入正确的密钥,之后每次加载程序时它都会自动显示 form2 (即我的实际程序)并跳过 form1强>。
顺便说一句,我知道还有其他更先进和更安全的方法可以做到这一点,但我目前只是对这种非常基本的方法感兴趣。
有人可以帮忙吗?
【问题讨论】:
-
考虑使用注册表或文件。
-
你应该为你的表单和控件命名。
-
您可以在 Program.cs 中决定加载哪个表单作为主表单。
-
@SLaks 如何使用注册表或文件?
-
查看
Microsoft.Win32.Registry类或命名空间System.IO。那里有大量教程,只需使用您选择的搜索引擎(即:谷歌)搜索它们
标签: c# winforms store activation-function