You need to access computer which is not in a domain?
No problem
Here is the code:
var token: Cardinal;
dwResult: DWORD;
nr: TNETRESOURCE;
sl: TStringList;
begin
nr.dwType := RESOURCETYPE_DISK;
nr.lpProvider := nil;
nr.lpLocalName := nil;
nr.lpRemoteName := '\\computername\sharedfolder';
//\\computername\sharedfolder\ will not work - just with ExcludeTrailingPathDelimiter
\\also will not work \\computername\d$\folder\ - we need just \\computername\d$
dwResult := WNetAddConnection2(nr, 'password', 'user', 0); //watchout username and pass are on strange positions, at least for me
if (dwResult = NO_ERROR) or (dwResult = ERROR_ALREADY_ASSIGNED) or (dwResult = ERROR_SESSION_CREDENTIAL_CONFLICT) then
begin
sl := TStringList.Create;
sl.LoadFromFile('\\computername\sharedfolder\file.txt');
ShowMessage(sl.Strings[1]);
FreeAndNil(sl);
end;
end;
Taken from here.