View previous topic :: View next topic |
Author |
Message |
BLFields Guest
|
Posted: Tue May 02, 2006 3:19 pm Post subject: Deleting CF registry keys |
|
|
During testing, the licensing keys tend to accumlate so I wrote a program to find the keys, list the keys in a listView object with check boxes so I could select the ones I wanted to delete. This approach works great for NF, but for CF OpenCF complains that the string I've submitted is not a registry key. I've tried every possible permutation of the registry string (with and without {}, with and without the registry value. This should work but doesn't:
//get the selected key
string strKey = listView1.Items[index].Text;
int length = strKey.LastIndexOf("}");
//remove the braces
strKey = strKey.Substring(0, length+1);
//delete the key
parentKey.DeleteSubKeyTree(strKey);
On the OpenCF forum there is a thread with the same complaint and a suggested change to the OpenCF code. I tried the change but it did not solve the problem.
There is apparently a problem with the OpenCF code when it comes to deleting keys and an exception will always be thrown that the key string submitted is not a registry key. Does anyone know what the problem is? |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue May 02, 2006 10:22 pm Post subject: |
|
|
Are you storing your license keys in the registry (by default ILS use a file to store the license key)?
If you are attempting to delete the registry entries made by the EvaluationMonitor then a better way would be to have your program call the EvaluationMonitor.Reset method. _________________ Infralution Support |
|
Back to top |
|
|
Guest
|
Posted: Wed May 03, 2006 3:20 pm Post subject: |
|
|
I don't want to reset the keys, I want to delete them.
I need to test the installation as if the program were being installed on a virgin PDA. I don't want an ILS key present until it is created. So I need a way to delete any and all accumulated keys. Have you tried to delete a registry key using OpenNetCF? |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed May 03, 2006 10:30 pm Post subject: |
|
|
EvaluationMonitor.Reset() actually does delete the key and all sub values using RegistryKey.DeleteSubKeyTree(name). I've just checked that this is working correctly under CF. _________________ Infralution Support |
|
Back to top |
|
|
Guest
|
Posted: Thu May 04, 2006 2:43 am Post subject: |
|
|
Well, you are exactly right. And the reason my code wasn't working was because it was necessary, apparently, to close the subkey. I note you not only closed it, but set it to null.
It would have been nice if OpenNetCF had issued an error that the key was open or couldn't be deleted instead of claiming that the string wasn't a registry key.
Anyway, I've got it working now. Thanks. |
|
Back to top |
|
|
|