Can you guys please help me with the following problem. The first time my application opens up, it should get the local date out of the System and store this in a registry key. But the second time it should get the date stored in that registryKey and compare it to the date right now.
And there is where I am stuck, I just don't know how to get the date out of that key and compare it to the date right now.
This is my code:
Expand|Select|Wrap|Line Numbers
- RegistryKey key1;
- private void btnTrial_Click(object sender, EventArgs e)
- {
- DateTime current = DateTime.Now;
- key1 = Registry.CurrentUser.OpenSubKey("myKey");
- if (key1 == null)
- {
- key1 = Registry.CurrentUser.CreateSubKey("myKey");
- key1.SetValue("StartTrialDate", current.ToShortDateString());
- key1.Close();
- using (mainForm mainform = new mainForm())
- {
- Hide();
- mainform.ShowDialog();
- Environment.Exit(0);
- }
- }
- if (key1 != null)
- {
- RegistryKey openKey = Registry.CurrentUser.OpenSubKey("myKey");
- if (openKey.GetValue("StartTrialDate") > current)
- {
- }
- }
- }
I hope you guys can help me out.
Thanks in advance,
Michael