Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting the sever name by letter
Message
From
05/11/1999 11:01:00
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00287179
Message ID:
00287547
Views:
18
This almost works, you need to loose the '\' in drive designation: e.g.

IF WNetGetConnection('Z:',@cBuffer,511) = 0


>>I have a win98 network
>>
>>I can I return the server name only by the letter
>>eg.
>> suppose i dont know the servers name.
>>
>>
>> c:\ returns \\computer1
>> d:\ returns \\computer2
>> e:\ returns \\computer3
>>
>> etc.
>>
>>I need to store that to a variable
>>
>
>If you have the Windows Scripting Host installed (which if everyone is running Win98, you do, you can get the information from the Wscript.Network object, which can return a collection of mapped drives and the UNC that they're mapped to via the EnumNetworkDrives method.
>
>You can also use the Win32 API to retrieve the UNC from a mapped drive using the WNetGetConnection() API call, something like:
>
>
DECLARE INTEGER WNetGetConnection IN Win32API ;
>   String @cLocalDrive, ;
>   String @UNCBuffer, ;
>   Integer @Buffersize
>cBuffer = space(511)
>IF WNetGetConnection('Z:\',@cBuffer,511) = 0
>   RETURN LEFT(cBuffer, RAT('\',cBuffer) - 1)
>ELSE
>   RETURN NULL
>ENDIF
>
>If you wanted the UNC, use AT(chr(0),cBuffer) rather than RAT('\',cBuffer)
>
>>
Previous
Reply
Map
View

Click here to load this message in the networking platform