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);
var
sl : TStrings;
nMappingsCount,
i : integer;
begin
sl := TStringList.Create;
nMappingsCount :=
GetNetworkDriveMappings( sl );
for i := 0 to nMappingsCount-1 do
begin
MessageBox( 0,
PChar( sl.Strings[ i ] ),
'Network sürücü tanimlari',
MB_OK );
end;
listbox1.items.assign(sl);
sl.Free;
end;
end.