0

I am writing a add-in for outlook. I want to ask password before inactivating the add-in. if password is not correct, Add-in shouldn't be inactive. While inactiving add-in it is firing "ThisAddIn_Shutdown" event but I can't block inactiving add-in.

This is my code:

 private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
 {
         var frm = new FrmCheck();
         var result = frm.ShowDialog();
          if (frm.Statu==WinStatu.Close && result == DialogResult.OK)
          {
                //password is correct. Close Add-in
          }
          else
          {
             //TODO:  cancel closing this add-in
              MessageBox.Show("You can't close this add-in, please enter valid password.");
          }
  }

Thanks.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Müslüm ÖZTÜRK
  • 961
  • 1
  • 11
  • 30
  • To achieve what you describe you would need to "hack" Outlook behaviour which is in place for security and stability reasons - IMHO there is no robust way to do what you want... WHY do you want to do this ? Perhaps there is a different way to achieve your goal... – Yahia May 28 '13 at 21:05

1 Answers1

0

You don't have any control over a user disabling an add-in - your best bet is to probably have a separate process/service that re-enables it as necessary. (It's just a case of editing the registry key that controls load behavior)

Ben Heymink
  • 1,700
  • 12
  • 26