Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UNC path
Message
De
30/07/2001 13:30:05
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00537252
Message ID:
00537319
Vues:
15
>I'm sitting here in front of a VFP training class telling them just how smart everyone out here is sooooooooo....
>
>How do you get a UNC path (\\ServerName\directory\file) from a absolute path like you get back from GetFile()?
>
>Come on now...don't make me look bad here...I'm counting on all you!

Hi Jim,
A rough version to do it :
#Define ERROR_NOT_CONNECTED 2250
#Define ERROR_MORE_DATA 234
#Define ERROR_BAD_DEVICE 1200
#Define ERROR_CONNECTION_UNAVAIL  1201
#Define ERROR_NO_NETWORK 1222
#Define ERROR_NO_NET_OR_BAD_PATH 1203
#Define ERROR_EXTENDED_ERROR 1208

#Define UNIVERSAL_NAME_INFO_LEVEL   0x00000001
#Define REMOTE_NAME_INFO_LEVEL      0x00000002
Declare integer WNetGetUniversalName in win32API ;
  string @ lpLocalPath, ;
  integer dwInfoLevel,  ;
  string @ lpBuffer,  ;
  integer @ lpBufferSize

Declare integer GetLongPathName in win32API ;
  string @ lpszShortPath, string @ lpszLongPath, integer cchBuffer

lpLocalPath = GetFile()

lpBufsize = 512
Store space(512) to lpBuffer,lpszLongPath
lnResult = WNetGetUniversalName(@lpLocalPath,REMOTE_NAME_INFO_LEVEL ,@lpBuffer,@lpBufsize)
If lnResult = ERROR_MORE_DATA && Buffer was small -retry with new bufsize
  lnResult = WNetGetUniversalName(@lpLocalPath,REMOTE_NAME_INFO_LEVEL ,@lpBuffer,@lpBufsize)
Endif
Do case
  Case lnResult=0
    lcInfo =  substr(lpBuffer,13)
    Alines(arrInfo,chrtran( substr( lcInfo,1,at(chr(0),lcInfo,3) ),chr(0),chr(13)))
    ? 'Full UNC path : '+arrInfo[1]
    ? 'Server path   : '+arrInfo[2]
    ? 'File Path     : '+arrInfo[3]
  Otherwise && Assume local path
    ? lnResult
    lnBuf = GetLongPathName(@lpLocalPath, @lpszLongPath, lpBufsize)
    ? substr(lpszLongPath,1,lnBuf)
Endcase
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform