public void Release() { NativeWin32API.CredFree(this.CredentialPtr); this.CredentialPtr = IntPtr.Zero; this.LiveAccounts.Clear(); this.LiveAccounts = null; this.IsSuccess = false; }
public bool GetAccountInformations() { bool Result; UInt32 Count = 0; LiveIdInformation Info = new LiveIdInformation(); LangMgr = new LanguageSupport(); IntPtr BufPtr = IntPtr.Zero; NativeWin32API.CREDENTIAL CurrentCredential; if (IsSuccess) { return(true); } Result = NativeWin32API.CredEnumerate("WindowsLive:name=*", 0, out Count, out CredentialPtr); if (Result) { LiveAccounts = new List <LiveIdInformation>((int)Count); BufPtr = CredentialPtr; for (int i = 0; i < Count; i++) { BufPtr = new IntPtr(BufPtr.ToInt32() + ((i == 0) ? 0 : Marshal.SizeOf(CredentialPtr))); CurrentCredential = (NativeWin32API.CREDENTIAL)Marshal.PtrToStructure(Marshal.ReadIntPtr(BufPtr), typeof(NativeWin32API.CREDENTIAL)); Info.LiveId = CurrentCredential.UserName; Info.Password = Marshal.PtrToStringUni(CurrentCredential.CredentialBlob); int LngIndex = System.Globalization.CultureInfo.CurrentCulture.Parent.NativeName == "English"? 1 : 0; if (Info.Password == null) { Info.Password = LangMgr["PwdNotSet"]; } LiveAccounts.Add(Info); } IsSuccess = true; } return(Result); }