var
path, filename: string;
filelist: TStringDynArray;
- Win32Result: integer;
+ lResult: Cardinal;
NR: TNetResource;
password, user: PChar;
begin
end;
password := PChar('');
user := PChar('');
- if WNetAddConnection2(NR, password, user, 0) = NO_ERROR then
+ lResult := WNetAddConnection2(NR, password, user, 0);
+ if lResult in [NO_ERROR, ERROR_ALREADY_ASSIGNED] then
begin
path := ExcludeTrailingPathDelimiter(NR.lpRemoteName);
NR.lpRemoteName := PChar(path);
filelist := TDirectory.GetFiles(path, '*.mp3',
TSearchOption.soAllDirectories);
- WNetCancelConnection2(NR.lpRemoteName, 0, False);
+ if lResult = NO_ERROR then
+ WNetCancelConnection2(NR.lpRemoteName, 0, False);
end;
for filename in filelist do
ListView1.Items.Add.Text := filename;