Exemplo n.º 1
0
        /// <summary>
        /// Get the Identifier from Windows Messenger which will return the Passport email address.
        /// If that fails, default to GetIdentifierFromWindows()
        /// </summary>
        /// <returns>string Identifier</returns>
        private static string GetIdentifierFromMessenger()
        {
            // Check Messenger for logon name
            try
            {
                // Create the messenger object
                MessengerAPI.MessengerClass msgr = new MessengerAPI.MessengerClass();

                // Assign the logon name
                return(msgr.MySigninName);
            }
            catch (Exception)
            {
                RegistryKey pcaKey = null;
                try
                {
                    pcaKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\MessengerService\\ListCache\\.NET Messenger Service");
                }
                catch (Exception) {}

                using (pcaKey)
                {
                    if (pcaKey != null)
                    {
                        object o = pcaKey.GetValue("IdentityName");
                        if (o != null)
                        {
                            return(Convert.ToString(o, CultureInfo.InvariantCulture));
                        }
                    }
                }

                return(GetIdentifierFromWindows());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the Identifier from Windows Messenger which will return the Passport email address.
        /// If that fails, default to GetIdentifierFromWindows()
        /// </summary>
        /// <returns>string Identifier</returns>
        private static string GetIdentifierFromMessenger()
        {

            // Check Messenger for logon name
            try
            {
                // Create the messenger object
                MessengerAPI.MessengerClass msgr = new MessengerAPI.MessengerClass();

                // Assign the logon name
                return msgr.MySigninName;

            }
            catch (Exception)
            {

                RegistryKey pcaKey = null;
                try
                {
                    pcaKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\MessengerService\\ListCache\\.NET Messenger Service");
                }
                catch (Exception) {}

                using (pcaKey)
                {
                    if (pcaKey != null)
                    {
                        object o = pcaKey.GetValue("IdentityName");
                        if (o != null)
                        {
                            return Convert.ToString(o, CultureInfo.InvariantCulture);
                        }
                    }
                }

                return GetIdentifierFromWindows();
            }
        }