Office::COMAddIn::put_Connect not working under VISTA

G

Gancev

Hi All,

I add my code below. The problem is that in Vista the function
put_connected is not working.
On Windows XP is working in all combination.On Windows Vista if I start
Outlook with "Run as admin" it works, otherwise not.
I used the link http://msdn.microsoft.com/en-us/library/bb386106.aspx and
copy all keys from Local to current user but still not working until I
delete this reg key
:"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Outlook\Addins\OneNote.OutlookAddin.12"
My purpose is to disable One Note add in for specific messages only, and
the solution should work even if user start Outlook without using "Run as"

void DisableOneNoteAddin(bool state){
CComPtr<Outlook::_Application> spApp = GetMainApplication();
CComPtr<Office::COMAddIns> spAddins;
CComPtr<Office::COMAddIn> spAddin;
spApp->get_COMAddIns(&spAddins);
if(spAddins){
long numaddins;
spAddins->get_Count(&numaddins);
if(numaddins>0){
for(int i = 1; i<=numaddins; i++){
CComBSTR name;
VARIANT var = CComVariant(i);
spAddin =spAddins->Item(&var);
spAddin->get_Description(&name);
if(name == _T("OneNote Notes about OutlookItems"))
{
if(state) spAddin->put_Connect(VARIANT_FALSE);
else spAddin->put_Connect(VARIANT_TRUE);
}
}}}}

THANKS,
Stojan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top