Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

Ag sürücülerinin tespiti

Sistemde tanimli olan ag sürücülerinin listesini elde etmek icin asagidaki fonksiyon kullanilabilir. unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; ListBox1: TListBox; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} function GetNetworkDriveMappings( sl : TStrings ) : integer; var i : integer; sNetPath : string; dwMaxNetPathLen : DWord; begin sl.Clear; dwMaxNetPathLen := MAX_PATH; SetLength( sNetPath, dwMaxNetPathLen ); for i := 0 to 25 do begin if( NO_ERROR = Windows.WNetGetConnection( PChar( '' + Chr( 65 + i ) + ':' ), PChar( sNetPath ), dwMaxNetPathLen ) )then begin sl.Add( Chr( 65 + i ) + ': ' + sNetPath ); end; end; Result := sl.Count; end; procedure TForm1.Button1Click(Sender: TObject); // // here's how to call GetNetworkDriveMappings(): // var sl : TStrings; nMappingsCount, i : integer; begin sl := TStringList.Create; nMappingsCount := GetNetworkDriveMappings( sl ); for i := 0 to nMappingsCount-1 do begin // //Istenen seyler burada yapilabilir. // Simdilik sadece görüntülensin // MessageBox( 0, PChar( sl.Strings[ i ] ), 'Tanimli Ag diskleri',MB_OK ); end; listbox1.items.assign(sl); sl.Free; end; end.