Lenguaje de programación Borland Delphi
Añadiremos un formulario, un botón y un TMemo con el nombre "mUnidadesDeRed". En el USES del formulario pondremos "Windows". En el evento click del botón pondremos el siguiente código:
procedure TformMenuPrincipal.Button1Click(Sender: TObject);
function GetNetworkDriveMappings (SList : TStrings) : Integer;
var
I : Char;
ThePath : String;
MaxNetPathLen : DWord;
begin
SList.Clear;
MaxNetPathLen := MAX_PATH;
SetLength(ThePath, MAX_PATH);
For I := 'A' to 'Z' Do
if WNetGetConnection(PChar('' + I + ':'), PChar(ThePath),
MaxNetPathLen) <> ERROR_NOT_CONNECTED then
SList.Add(I + ': ' + ThePath);
{Devuelve el numero de conexiones}
Result := SList.Count;
end;
begin
GetNetworkDriveMappings(mUnidadesDeRed.Lines);
end;
Publicado el: 2003-10-14