Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server-String of a maped Drive

Status
Not open for further replies.

Hannes214

IS-IT--Management
Jan 30, 2006
45
DE
Hi

I have an other good question...

I have the character of a maped drive.. for example: G

Now, how can i receive the server-string for that drive G ... for example: \\Server1\folder2


IT-Management
( FoxPro-Newbi :eek:) )
 
Code:
Function GetNameFromLetter(cDriveLetterToCheck)
    LOCAL cBuffer, nResult
    IF VARTYPE(cDriveLetterToCheck) # 'C'    OR ;
       LEN(cDriveLetterToCheck) < 2          OR ;
       SUBSTR(cDriveLetterToCheck,2,1) # ':' OR ;
       NOT  BETWEEN(UPPER(LEFT(cDriveLetterToCheck,1)),'A','Z')
   RETURN ''
ENDIF

DECLARE INTEGER WNetGetConnection IN Win32API ;
   STRING   @cLocalDrive, ;
   STRING   @cRemoteUNCBuffer, ;
   INTEGER  @nSizeOfBuffer
cBuffer = SPACE(511)
nResult = WNetGetConnection(LEFT(cDriveLetterToCheck,2), ;
                            @cBuffer, ;
                            511)
IF nResult # 0
   *  Failed - it's probably not a mapped drive,
   *  or nothing is mapped to it
   RETURN ''
ELSE
   RETURN LEFT(cBuffer,AT(CHR(0),cBuffer)-1)
ENDIF

Borislav Borissov
 
thx Borislav

..but how can I use that code?



IT-Management
( FoxPro-Newbi :eek:) )
 
ok.. all ok.. that works fine.. big thx

IT-Management
( FoxPro-Newbi :eek:) )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top