Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Any API call to get the Base path from a UNC path?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00180686
Message ID:
00180991
Vues:
13
>Hi Ed and George!
>
>Here is the reason for my request.
>
>When using NetFileEnum, you need to provide a server as well as, a base path.
>
>In my example, if I want to find out who has \\continuum\putz\recon\recon_check.dbf opened, I would have to call NetFileENum passing "\\continuum" as my server, and "d:\putz\recon\recon_check.dbf" as the base path (this is the physical base path on that server, NOT a mapping).
>
>My issue is that, if I need to know who is using \\continuum\putz\recon\recon_check.dbf, I have no way of knowing what the actual path is on the workstation/server. Therefore, I need to have \\continuum\putz\recon\recon_check.dbf be evaluated as d:\putz\recon\recon_check.dbf".

I think you'd be better off buying a solution off-the shelf, but you can do it using a few(!) more API calls.

NetShareEnum() can return the information you need in a level 2 or level 502 type request. If you don't need the SD details, I'd stick with a level 2 structure. You can enumerate all the shares and retrieve their local paths, and then use the shares and paths to reference the files that everyone has open that were gotten with NetFileEnum().
DECLARE INTEGER NetShareEnum IN WIN32API ;
   STRING lpServername, ;
   INTEGER dwLevel, ;
   INTEGER bufptr, ;
   INTEGER dwMaxLength, ;
   INTEGER @entriesread, ;
   INTEGER @total_entries, ;
   INTEGER @resume_handle
Set lpServerName to the server you want to enumerate, dwLevel = 2 at the start, dwMaxLength to some multiple of the size of a SHARE_INFO_2 structure, and all other values to 0. You have to spin through list of shares for the server; each time you call, you'll be handed back a buffer pointed to by bufptr, which will contain an array of SHARE_INFO_2 structures. You'll want to save the share name and local path members of the structure (you can use GetMem() and GetMemString() from CLSHEAP to copy the buffer to a VFP string, and to retrieve the null terminated strings within the structure respectively. When you've finished with the buffer, you need to dispose of it with NetApiBufferFree().

It's a lot of code; NETLIB or another third-party library or control might be a better investment of resources and time.


>
>Ed, I tried implementing your sample source, however, I can not instansiate Wscript.Network. What am I missing? Currently using WIN/NT 4.0 w/SP3.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform