2016-03-31 3 views
0

Ich möchte überprüfen, ob Outlook auf bestimmten Computer installiert und für den aktuellen Benutzer konfiguriert ist. Ich verwende Code unten ...Wie Outlook zu überprüfen ist für den aktuellen Benutzer konfiguriert

private static bool IsOutlookProfileConfigured2() 
     { 
      try 
      { 
       RegistryKey currentUser = Registry.CurrentUser; 
       RegistryKey regWMSprofile = currentUser.OpenSubKey 
       (@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"); 
       if (regWMSprofile == null) 
       { 
        regWMSprofile = currentUser.OpenSubKey 
       (@"Software\Microsoft\Office\15.0\Outlook\Profiles"); 
        if (regWMSprofile == null) 
        { 
         return false; 
        } 
        Console.WriteLine(@"Found on path==>Software\Microsoft\Office\15.0\Outlook\Profiles"); 
       } 
       else 
       { 
        Console.WriteLine(@"Found on path==>SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"); 
       } 

       Outlook.Application OlApplication = new Outlook.Application(); 

       if (regWMSprofile.SubKeyCount > 0) 
       { 
        if (OlApplication == null) 
        { 
         return false; 
        } 
        Outlook.NameSpace olNameSpace = 
        OlApplication.GetNamespace("MAPI"); 

        if (olNameSpace != null && olNameSpace.Accounts != 
        null && olNameSpace.Accounts.Count > 0) 
        { 
         return true; 
        } 
       } 
       else 
       { 
        return false; 
       } 

      } 
      catch (Exception ex) 
      { 
       return false; 
      } 

      return false; 
     } 

Methode sagt Outlook-Profil auf "Software \ Microsoft \ Office \ 15.0 \ Outlook \ Profiles" zu finden ist.

Outlook 2013 ist auf dem Benutzercomputer installiert, aber nicht konfiguriert.

Diese Methode öffnet den Outlook Profil-Konfigurationsassistenten.

Kann mir jemand helfen, diese Funktion oder einen Beispielcode zu reparieren, der prüft, ob Outlook für den aktuellen Benutzer konfiguriert ist und den Profilkonfigurationsassistenten nicht starten sollte.

Vielen Dank im Voraus.

+0

Hat das Profil in "Software \ Microsoft \ Office \ 15.0 \ Outlook \ Profiles \ Outlook" haben alle Unterschlüssel? –

+0

Ja ... Es hat Unterschlüssel .. einige GUID – Abhash786

+0

Nur eine? Normale Profile haben einige Unterschlüssel. –

Antwort

Verwandte Themen