>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
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