Example #1
0
        private void unrar_PasswordRequired(object sender, PasswordRequiredEventArgs e)
        {
            FrmTextInput dialog = new FrmTextInput();

            dialog.Prompt       = string.Format("请输入密码");
            dialog.PasswordChar = '*';
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                e.Password          = dialog.Value;
                e.ContinueOperation = true;
            }
            else
            {
                e.ContinueOperation = false;
            }
        }
Example #2
0
        protected virtual int OnPasswordRequired(IntPtr p1, int p2)
        {
            int result = -1;

            if (this.PasswordRequired != null)
            {
                PasswordRequiredEventArgs e = new PasswordRequiredEventArgs();
                this.PasswordRequired(this, e);
                if (e.ContinueOperation && e.Password.Length > 0)
                {
                    for (int i = 0; (i < e.Password.Length) && (i < p2); i++)
                    {
                        Marshal.WriteByte(p1, i, (byte)e.Password[i]);
                    }
                    Marshal.WriteByte(p1, e.Password.Length, (byte)0);
                    result = 1;
                }
            }
            else
            {
                throw new IOException("Password is required for extraction.");
            }
            return(result);
        }