Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Detect remote drive

8 views
Skip to first unread message

Alex Barski

unread,
Oct 19, 1998, 3:00:00 AM10/19/98
to
I have map network drive Z: CompXxx\\Path\ on my computer
Can I retrive string 'CompXxx\\Path\' by string 'Z:'

Sorry, my english is'nt well.
--
+---------------------------------+
| Instytut Badań Systemowych PAN |
| Aleksy Barski |
| mailto:al...@ibspan.waw.pl |
| http://www.ibspan.waw.pl/~alex/ |
+---------------------------------+

Peter Below

unread,
Oct 19, 1998, 3:00:00 AM10/19/98
to
> I have map network drive Z: CompXxx\\Path\ on my computer
> Can I retrive string 'CompXxx\\Path\' by string 'Z:'

Use WNetGetConnection. Here is an example:

{************************************************************
* Function IsNetworkDrive
*
* Parameters:
* drive: drive letter to check. Case does not matter.
* Returns:
* True if this is a network drive, false if otherwise. Note that
* on Win 3.1 a CD-ROM will be returned as a network drive!
* Call method:
* static
* Description:
* Uses the API function GetDriveType to check the type of the
* passed drive.
* Error Conditions:
* None
*
*Created: 18.05.97 11:59:24 by P. Below
************************************************************}
Function IsNetworkDrive( drive: Char ): Boolean;
Var
root: Array [0..4] Of Char;
Begin
StrCopy( root, '?:\' );
root[ 0 ] := UpCase( drive );
Result:= GetDrivetype( {$IFDEF WIN32} root
{$ELSE} Ord( root[ 0 ] ) - Ord( 'A' ) {$ENDIF}
) = DRIVE_REMOTE;
End; { IsNetworkDrive }

{************************************************************
* Function DriveToService
*
* Parameters:
* drive: driveletter to check
* Returns:
* Service name of the service connected to the drive, or an
* empty string, if the drive is not connected at all.
* Description:
* Uses API functions to retrieve the service name, if the
* drive is a remote drive.
* Error Conditions:
* none
*
*Created: 06.05.97 15:44:10 by P. Below
************************************************************}
Function DriveToService( drive:Char ): String;
Var
localname : Array [ 0..4 ] of Char;
remotename : Array [0..80] Of Char;
bufsize: {$IFDEF WIN32} DWORD {$ELSE} Word {$ENDIF};
Begin
Result := EmptyStr;
If IsNetworkDrive( drive ) Then Begin
StrCopy( localname, '?:' );
localname[ 0 ] := UpCase( drive );
bufsize := Sizeof( remotename );
If WNetGetConnection( localname, remotename,
{$IFDEF WIN32} bufsize
{$ELSE} @bufsize {$ENDIF}
) = WN_SUCCESS
Then
Result := StrPas( remotename );
End; { If }
End; { DriveToService }

Peter Below (TeamB) 10011...@compuserve.com)
No replies in private e-mail, please, unless explicitely requested!


0 new messages