Ads 468x60px

Smaller time frame always follow the bigger time frame. It's better wait be patience to enter in position than risk with BIG SL. Having strong trading discipline and taking losses when necessary is a sign of serious trading approach
Subscribe:

Labels

Saturday, August 11, 2012

FUNCTION TO LIST ALL THE NETWORK DRIVE MAPPINGS

It is very easy to get a list of all the network drive mappings using the following function. Please note that you must create and free the string list that you pass to it. The return value indicates the number of network mappings GetNetworkDriveMappings() was able to find. 

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;

//
// 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
    //
    // do your thing here...
    // for now, we'll just display the mapping
    //
    MessageBox( 0,
      PChar( sl.Strings[ i ] ),
      'Network drive mappings',
      MB_OK );
  end;
  sl.Free;
end;

comments