Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ServerName
Message
De
08/10/2014 13:14:23
Al Doman (En ligne)
M3 Enterprises Inc.
North Vancouver, Colombie Britannique, Canada
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP3
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01608992
Message ID:
01609009
Vues:
80
>Hi Gang!
>
>Question - We need to get the SERVER NAME of a server, determined from a foxpro (or other language) program, running ON the Server, OR running from one of the WORKSTATIONS.

A VFP process running on the server computer can get its name using SYS( 0 ), which will return something like "ServerName # UserName".

From a workstation: one way is if you know you have a drive letter mapped to a share on the server e.g. drive F:. You can use the code below:
FUNCTION Device2UNC
* Pass in a mapped drive letter e.g.
* lcUNC = Device2UNC( "F:" )

LPARAMETERS ;
	tcLocalName

LOCAL ;
	lcUNCBuffer ;
	, lnLength ;
	, lcLocalName ;
	, lcRemoteName

DECLARE INTEGER WNetGetConnection IN WIN32API ;
	STRING lpLocalName, STRING @ lpRemoteName, INTEGER @ lplnLength


lcLocalName = ALLTRIM( tcLocalName )
lcUNCBuffer = REPLICATE( CHR( 0 ), 1024 )
lnLength = LEN( lcUNCBuffer )

IF WNetGetConnection( lcLocalName, @lcUNCBuffer, @lnLength ) = 0
	lcRemoteName = LEFT( lcUNCBuffer, AT( CHR( 0 ), lcUNCBuffer ) - 1)

ELSE
	lcRemoteName = ""

ENDIF

RETURN lcRemoteName
The result will be something like "\\ServerName\ShareName"
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform