Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Network Information
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00148590
Message ID:
00148596
Views:
12
>Does anyone know if there is a way to get a computers (other than your own)network name. I know about sys(0) but that returns my computer name. If i map a drive as e:\. Is there a way to get that computer's network name and information.
>
>Thank you for any help.
>Jeff Cooper

Hi Jeff,

The following function will do the trick:
FUNCTION ConnectName
  * Returns the name of the device
  LPARAMETER pc_device

  DECLARE INTEGER WNetGetConnection IN Win32API;
    STRING @lpszLocalName, STRING @lpbuffer, INTEGER @lnbufsize
  LOCAL lcresult, lcdevice, lcbuffer, lnsize, lnerr 
  lcresult = ""
  lcbuffer = SPACE(200) + CHR(0)
  lnsize = LEN(lcbuffer)
  lcdevice = pc_device
  IF RIGHT(lcdevice, 1) # CHR(0)
    lcdevice = lcdevice + CHR(0)
  ENDIF
  lnerr = WNetGetConnection(@lcdevice, @lcbuffer, @lnsize) 
  IF lnerr = 0
    lcresult = LEFT(lcbuffer, AT(CHR(0), lcbuffer) - 1)
  ENDIF
  RETURN lcresult
ENDFUNC
hth,
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform