Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting the sever name by letter
Message
De
05/11/1999 11:01:00
 
 
À
04/11/1999 17:18:23
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00287179
Message ID:
00287547
Vues:
19
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)
>
>>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform