using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace PwdFiltTest
{
public partial class PwdFiltTest : Form
{
public struct UNICODE_STRING
{
public ushort Length;
public ushort MaximumLength;
public IntPtr Buffer;
}
[DllImport("PwdFilt.dll")]
public static extern bool PasswordFilter(
ref UNICODE_STRING UserName,
ref UNICODE_STRING FullName,
ref UNICODE_STRING Password,
bool SetOperation
);
public PwdFiltTest()
{
InitializeComponent();
}
private void pushCheck_Click(object sender, EventArgs e)
{
CheckPassword();
}
private void CheckPassword()
{
string sPassword = textPasswordToCheck.Text;
ushort length = (ushort)(sPassword.Length * 2);
ushort maximumlength = (ushort)(length + 2);
UNICODE_STRING unicode_string = new UNICODE_STRING();
unicode_string.Buffer = Marshal.StringToHGlobalUni(sPassword);
unicode_string.Length = length;
unicode_string.MaximumLength = maximumlength;
bool ok = PasswordFilter(ref unicode_string, ref unicode_string, ref unicode_string, true);
chkPasswordOK.Checked = ok;
}
}//class
}//namespace