跟小D每日学口语

Win32 API ChangePassword

[DllImport("Netapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    private static extern int NetUserChangePassword(
        string domainname,
        string username,
        string oldpassword,
        string newpassword
        );
    public static bool ChangePassword(string username, string domain, string oldpassword, string newpassword) {
        int result = NetUserChangePassword(
            domain,
            username,
            oldpassword,
            newpassword
            );
        if (result != 0)
            //throw new Win32Exception();
            return false;

        return true;
    }

posted @ 2008-06-18 10:19  javak  阅读(379)  评论(0编辑  收藏  举报