List All Network Drives

Submitted by:Pitter Alderson

Date added:18 April, 2012

Category:Delphi

To show a list of all mapped network drives, use the GetNetworkDriveMappings function

Tags: list drives

Code Snippet:

GetNetworkDriveMappings(Memo1.Lines) ;

function GetNetworkDriveMappings (SList: TStrings): integer;
var
c: Char;
ThePath: string;
MaxNetPathLen: DWord;
begin
SList.Clear;
MaxNetPathLen := MAX_PATH;
SetLength(ThePath, MAX_PATH) ;
for c := 'A' to 'Z' do
if WNetGetConnection(PChar('' + c + ':'), PChar(ThePath),MaxNetPathLen) = NO_ERROR then sList.Add(c + ': ' + ThePath) ;
Result := SList.Count;
end;
 
 

Comments