Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

Get list of network drives

Title: Get list of network drives To get list of all network drives, use WNetGetConnection function. procedure TForm1.Button1Click(Sender: TObject); var Drive: Char; PathStr: array[0..MAX_PATH] of Char; LPathStr: DWord; begin LPathStr:=MAX_PATH; with Memo1.Lines do begin Clear; for Drive:='A' to 'Z' do if WNetGetConnection( PChar(''+Drive+':'), PathStr, LPathStr)=NO_ERROR then Add(Drive); if Count=0 then Add('You have not network drives'); end; end;