Search results for 'WNetGetConnection'. 2 post(s) found.

  1. 2007/09/18 List All Network Drives
  2. 2007/09/10 Convert a mapped drive to a full UNC path
2007/09/18 08:31

List All Network Drives


To show a list of all mapped Network Drives, use the GetNetworkDriveMappings function. Example usage:

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;
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 02:56 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 12:03 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:40 delete

    moneyideas

2007/09/10 12:19

Convert a mapped drive to a full UNC path


Universal/Uniform Naming Convention. A UNC Path describes the location of a volume, directory, or file.

The format for a UNC Path is \\server\volume\directory\file and is not case-sensitive. For example:

    \\Shared1_svr\Shared1\WGroups\Network\Orders.xls

Rather than describe the location of a file or directory by drive letter, the Network Group will typically communicate a UNC Path to describe the actual location of a file or directory. Windows drive letter mappings are arbitrary, whereas a UNC Path is specific and applies to all operating systems.

Note: The UNC method started with the UNIX operating system. UNIX uses the forward-slash character as a path separator. Many network services (ex. FTP) have their origins in the UNIX operating system, so they use forward-slashes instead of the backslashes that DOS/Windows uses. It is important to recognize this distinction when using these services.

Usage:
UNCLabel.Caption := ConvertToUNCPath(ExtractFileDrive(Edit1.Text)) ;

Followings are the source can get UNC Path.
function ConvertToUNCPath(MappedDrive: string) : string;
var
   RemoteString : array[0..255] of char;
   lpRemote : PChar;
   StringLen : Integer;
begin
  lpRemote := @RemoteString;
  StringLen := 255;
   If WNetGetConnection(Pchar(ExtractFileDrive(MappedDrive)) ,
                        lpRemote,
                        StringLen) = NO_ERROR Then
     Result := RemoteString
   Else
     Result:=''; // Alternatively return an errorcode, Raise an exception or something like end;
end;

Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 04:40 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 13:32 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:38 delete

    moneyideas