Я делал так:
1. Создавал сетевой диск/папку (проходил аунтефикацию, добовлял в систему)
2. работал с файлами.
3. дисконект
Код:
//-------------connect-------------------------
var
lpNetResource: TNetResource;
strMessage: string;
nError: DWORD;
begin
with lpNetResource do
begin
dwType := RESOURCETYPE_DISK;
lpLocalName := 'Y:';
lpRemoteName := '\\10.101.0.21\Новая1';
lpProvider := '';
end;
nError := WNetAddConnection2(lpNetResource, 'password', 'login', 0);
case nError of
ERROR_ACCESS_DENIED: strMessage :=
'Access to the network resource was denied.';
ERROR_ALREADY_ASSIGNED: strMessage :=
'The local device specified by lpLocalName is already connected to a network resource.';
ERROR_BAD_DEV_TYPE: strMessage :=
'The type of local device and the type of network resource do not match.';
ERROR_BAD_DEVICE: strMessage :=
'The value specified by lpLocalName is invalid.';
ERROR_BAD_NET_NAME: strMessage :=
'The value specified by lpRemoteName is not acceptable to any network resource provider. The resource name is invalid, or the named resource cannot be located.';
ERROR_BAD_PROFILE: strMessage :=
'The user profile is in an incorrect format.';
ERROR_BAD_PROVIDER: strMessage :=
'The value specified by lpProvider does not match any provider.';
ERROR_BUSY: strMessage :=
'The router or provider is busy, possibly initializing. The caller should retry.';
ERROR_CANCELLED: strMessage :=
'The attempt to make the connection was cancelled by the user through a dialog box from one of the network resource providers, or by a called resource.';
ERROR_CANNOT_OPEN_PROFILE: strMessage :=
'The system is unable to open the user profile to process persistent connections.';
ERROR_DEVICE_ALREADY_REMEMBERED: strMessage :=
'An entry for the device specified in lpLocalName is already in the user profile.';
ERROR_EXTENDED_ERROR: strMessage :=
'A network-specific error occured. Call the WNetGetLastError function to get a description of the error.';
ERROR_INVALID_PASSWORD: strMessage := 'The specified password is invalid.';
ERROR_NO_NET_OR_BAD_PATH: strMessage :=
'A network component has not started, or the specified name could not be handled.';
ERROR_NO_NETWORK: strMessage := 'There is no network present.';
ERROR_LOGON_FAILURE: strMessage :=
'Logon failure: unknown user name or bad password.';
ERROR_BAD_NETPATH: strMessage := 'The network path was not found.';
ERROR_SESSION_CREDENTIAL_CONFLICT: strMessage :=
'The credentials supplied conflict with an existing set of credentials.';
else
strMessage := 'No Error';
end;
if nError <> NO_ERROR then
strMessage := 'Error-' + IntToStr(nError) + #13 + strMessage
else
strMessage := 'Error-' + IntToStr(nError);
ShowMessage(strMessage);
end;
//--------disconnect-----
WNetCancelConnection('Y:', True);