Ver Mensaje Individual
  #2  
Antiguo 19-01-2016
noobdelphi5 noobdelphi5 is offline
Miembro
NULL
 
Registrado: ene 2015
Posts: 22
Reputación: 0
noobdelphi5 Va por buen camino
Unhappy

Encontré esta función para conectar unidades de red la utilizo después de borrar la unidad anterior con

Código Delphi [-]
WNetCancelConnection(PChar(unidad),True);

Pero igualmente me corre si la ejecuto con botón pero no corre en un servicio, la función:

Código Delphi [-]
function ConnectShare(Drive, RemotePath, UserName, Password : String):Integer;
var
  NRW : TNetResource;
begin
  with NRW do
  begin
    dwType := RESOURCETYPE_ANY;
    if Drive <> '' then
      lpLocalName := PChar(Drive)
    else
      lpLocalName := nil;
      lpRemoteName := PChar(RemotePath);
      lpProvider := '';
  end;
  Result := WNetAddConnection2(NRW, PChar(Password), PChar(UserName), 0);
end;

function DisconnectShare(Drive : String):Integer;
begin
  Result := WNetCancelConnection2(PChar(Drive), 0, false);
end;

El resultado que me devuelve cuando se ejecuta es 1312:

ERROR_NO_SUCH_LOGON_SESSION
1312 (0x520)
A specified logon session does not exist. It may already have been terminated.
Responder Con Cita