function NetUserChangePassword(Domain: PWideChar; UserName: PWideChar; OldPassword: PWideChar; NewPassword: PWideChar): Longint; stdcall; external 'netapi32.dll' Name 'NetUserChangePassword'; // Changes a user's password for a specified network server or domain. // Requirements: Windows NT/2000/XP // Windows 95/98/Me: You can use the PwdChangePassword function to change a user's // Windows logon password on these platforms procedure TForm1.Button1Click(Sender: TObject); begin NetUserChangePassword(PWideChar(WideString('\\COMPUTER')), PWideChar(WideString('username')), PWideChar(WideString('oldpass')), PWideChar(WideString('newpass'))); end; 记住,要有管理员的权限
NET_API_STATUS NetUserChangePassword( LPCWSTR domainname, LPCWSTR username, LPCWSTR oldpassword, LPCWSTR newpassword );domainname [in] Pointer to a constant string that specifies the DNS or NetBIOS name of a remote server or domain on which the function is to execute. If this parameter is NULL, the logon domain of the caller is used. Windows NT: This string must begin with \\.
NewPassword: PWideChar): Longint; stdcall; external 'netapi32.dll'
Name 'NetUserChangePassword'; // Changes a user's password for a specified network server or domain.
// Requirements: Windows NT/2000/XP
// Windows 95/98/Me: You can use the PwdChangePassword function to change a user's
// Windows logon password on these platforms procedure TForm1.Button1Click(Sender: TObject);
begin
NetUserChangePassword(PWideChar(WideString('\\COMPUTER')),
PWideChar(WideString('username')),
PWideChar(WideString('oldpass')),
PWideChar(WideString('newpass')));
end; 记住,要有管理员的权限
LPCWSTR domainname,
LPCWSTR username,
LPCWSTR oldpassword,
LPCWSTR newpassword
);domainname
[in] Pointer to a constant string that specifies the DNS or NetBIOS name of a remote server or domain on which the function is to execute. If this parameter is NULL, the logon domain of the caller is used. Windows NT: This string must begin with \\.