Get a list
over all network drive mappings
2001-04-27
19:30:51 ZieglerSoft Ratings: 0, Votes: 0
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)=NO_ERROR
Then
SList.Add(I+':
'+ThePath);
Result :=
SList.Count;
End;
To test it,
drop a TListbox and a TButton on the form (ListBox1 and Button1). In the
buttons Click-event, make this code:
Procedure
TForm1.Button1Click(Sender: TObject);
Begin
GetNetworkDriveMappings(Form1.ListBox1.Items);
End;