Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Network Information
Message
From
20/10/1998 15:24:09
 
 
To
20/10/1998 14:32:01
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00148590
Message ID:
00148607
Views:
16
>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.
>

Yes, but it requires using an API call or automation object to get the information. For example, if you have a drive mapped as drive E:, you can retrieve the UNC for the mapping by calling the Win32 API function WNetGetConnection() to return the UNC associated with the mapped drive. As an example:
DECLARE INTEGER WNetGetConnection IN Win32API ;
 STRING   @cLocalDrive, ;
 STRING   @cRemoteUNCBuffer, ;
 INTEGER  @nSizeOfBuffer

cBuffer = SPACE(256)
nBufSize = 256
=WNetGetConnection('E:\',@cBuffer,@nBufSize)
? 'The UNC of E: is ' + LEFT(cBuffer, nBufSize-1)
UNCs are formed as \\\\, so that you can extract the name of the machine providing the share from the UNC returned above. For example, if the above returned the UNC "\\MyServer\SharedFolder", the host machine is "MyServer", and you are referencing the share named "SharedFolder". In the case of an MSNetwork share, the physical drive and directory reference is not directly extractable, since the share name is not related to physical drive and path; in the case of Novell NetWare, the share name is derived from the file server volume and directory name. In the case of a Novell server, if the UNC came back as "\\FS1\VOL1\MyDir", the share is provided by the file server "FS1", and the drive is mapped to FS1's VOL1:MyDir directory.

There are other Win32 API calls that can retrieve the names of systems visible to your computer and their shares. WNetOpenEnum() and WNetEnumResources() would most likely be useful in these cases. You'll need to look at the Win32 API documentation to see exactly what you need to do.

If you are running on systems that have the Windows Scripting Host installed, it's even easier to get at this information by instantiating the Wscript.Network object and examining the object's EnumNetworkDrives collection.

Both the Win32 API and the Windows Scripting Host are well-documented in the MSDN and Visual Studio Help Files. The MSDN information can be accessed on line from Microsoft's MSDN OnLine web pages; the MSDN Help files are provided as a part of an MSDN subscription, and Visual Studio includes this information as a part of the two CD help file data in Visual Studio.
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
Previous
Reply
Map
View

Click here to load this message in the networking platform