Moin,
ich habe deinen Code etwas "umgeschrieben":
Delphi-Quellcode:
const
UF_PASSWD_NOTREQD = 32;
UNLEN = 20; // 256 for groupnames
NERR_SUCCESS = 0;
TYPE
USER_INFO_1 = record
usri1_name: LPWSTR;
usri1_password: LPWSTR;
usri1_password_age: DWORD;
usri1_priv: DWORD;
usri1_home_dir: LPWSTR;
usri1_comment: LPWSTR;
usri1_flags: DWORD;
usri1_script_path: LPWSTR;
end;
TUserInfo1 = USER_INFO_1;
PUserInfo1 = ^TUserInfo1;
function PasswordNotRequired: Boolean;
var
ui: PUserInfo1;
p: Pointer absolute ui;
un: WideString;
n: Cardinal;
begin
p := nil;
n := Succ(UNLEN);
SetLength(un, UNLEN);
Result := GetUserNameW(@un[1], n)
and (NetUserGetInfo(nil, @un[1], 1, p) = NERR_SUCCESS)
and ((ui.usri1_flags and UF_PASSWD_NOTREQD) = UF_PASSWD_NOTREQD);
if Assigned(p) then
NetApiBufferFree(p);
end;
Grüße vom marabu