public void UnPack(bool decryptProtectedCredentials, out SecureString userName, out SecureString domainName, out SecureString password)
        {
            var pUserName      = new SafeCoTaskMemString(CredUI.CRED_MAX_USERNAME_LENGTH);
            var pDomainName    = new SafeCoTaskMemString(CredUI.CRED_MAX_USERNAME_LENGTH);
            var pPassword      = new SafeCoTaskMemString(CredUI.CREDUI_MAX_PASSWORD_LENGTH);
            int userNameSize   = pUserName.Size;
            int domainNameSize = pDomainName.Size;
            int passwordSize   = pPassword.Size;

            if (!CredUI.CredUnPackAuthenticationBuffer(decryptProtectedCredentials ? 0x1 : 0x0, buffer, bufferSize,
                                                       (IntPtr)pUserName, ref userNameSize, (IntPtr)pDomainName, ref domainNameSize, (IntPtr)pPassword, ref passwordSize))
            {
                throw new Win32Exception();
            }

            userName   = pUserName.DangerousGetHandle().ToSecureString();
            domainName = pDomainName.DangerousGetHandle().ToSecureString();
            password   = pPassword.DangerousGetHandle().ToSecureString();
        }
        public void UnPack(bool decryptProtectedCredentials, out string userName, out string domainName, out string password)
        {
            var pUserName      = new StringBuilder(CredUI.CRED_MAX_USERNAME_LENGTH);
            var pDomainName    = new StringBuilder(CredUI.CRED_MAX_USERNAME_LENGTH);
            var pPassword      = new StringBuilder(CredUI.CREDUI_MAX_PASSWORD_LENGTH);
            int userNameSize   = pUserName.Capacity;
            int domainNameSize = pDomainName.Capacity;
            int passwordSize   = pPassword.Capacity;

            if (!CredUI.CredUnPackAuthenticationBuffer(decryptProtectedCredentials ? 0x1 : 0x0, buffer, bufferSize,
                                                       pUserName, ref userNameSize, pDomainName, ref domainNameSize, pPassword, ref passwordSize))
            {
                throw new Win32Exception();
            }

            userName   = pUserName.ToString();
            domainName = pDomainName.ToString();
            password   = pPassword.ToString();
        }