none
How do I remove registry entries created by MessageInterceptor class?

    Question

  • Hi All

    I have used MessageInterceptor class to block SMS's based on sender's number in my project.

    There is no problem creating the Registry entries. here is the code.............works fine...........

                        string appPath = Assembly.GetExecutingAssembly().GetName().CodeBase;
                        mi = new MessageInterceptor[blackList.Length];

                            for (int i = 0; i < blackList.Length; i++)
                            {
                                mi[i] = new MessageInterceptor(InterceptionAction.NotifyAndDelete, false);

                                mi[i].MessageCondition = new MessageCondition(MessageProperty.Sender,                                                                                                                                                            MessagePropertyComparisonType.Contains, blackList[i], true);
                                mi[i].EnableApplicationLauncher("InterceptSMS" + i, appPath);
                                mi[i].MessageReceived += new MessageInterceptorEventHandler(InterceptSMS_MessageReceived_OnThread);


                            }

    Here, blacklist has the list of contacts from which we want to block the SMS's.

    I am using the following code to remove the registry entries

                        mi = new MessageInterceptor[blackList.Length];

                        for (int i = 0; i < blackList.Length; i++)
                        {
                            mi[i] = new MessageInterceptor("InterceptSMS" + i);
                        }

                         Remove the rules from the Registry
                        for (int i = 0; i < blackList.Length; i++)
                        {
                                                          //Remove registry entries
                            mi[i].MessageReceived -= new MessageInterceptorEventHandler(InterceptSMS_MessageReceived_OnThread);
                            mi[i].DisableApplicationLauncher();
      
                            mi[i].Dispose();                                                    //Dispose objects
                        }


    If I use mi[i].DisableApplicationLauncher();, the rules are unregistered, but the key still remaim with some GUID as its name instead of InterceptSMSx.

    If I use  mi[i].MessageReceived -= new MessageInterceptorEventHandler(InterceptSMS_MessageReceived_OnThread);, I get NullReferenceException.

    If I use
    mi[i].MessageReceived += InterceptSMS_MessageReceived_OnThread;
    ....................
    mi[i].MessageReceived -= InterceptSMS_MessageReceived_OnThread;
    I get compile time error
    Method 'SMP_SMSIC_Antispam.InterceptSMS.InterceptSMS_MessageReceived_OnThread(object, Microsoft.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptorEventArgs)' referenced without parentheses.

    What I have noticed is that there are no problems what so ever if the application is running continously. Basically, what I want is that the user can completely quit the application. When he restarts the application, he can get all the settings from the registry (the settings of the overall application also, which I have stored at another location). There is absolutely no issue in that. But when I try to unregister the application after restarting it, I get the above errors.

    Now, how do I remove the registry entries from the registry. I have designed the application such that when applying some different filtering scheme, it will first unregister the previous entries, and then apply new scheme (i.e. create new Registry entries). And the previous entries remain there, though GUID's as their names.

    You know this is a serious issue.

    THANX in advance

    Kumar Kush (Impetus Infotech (India) Pvt. Ltd.)
    Tuesday, June 17, 2008 5:12 PM