Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sys(0)- does it now work??
Message
De
01/07/1998 12:18:42
 
 
À
01/07/1998 00:18:17
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00113097
Message ID:
00113441
Vues:
21
>>>In Fox 2x there was a know problem with sys(0) in that it did not recognize some configurations of Novell. Has this problem been fixed to the point that I can be confident that Sys(0) will always tell me the network name of a computer? Thanks... Calvin
>>
>>In VFP, You'd be better off calling the API function GetComputerName:
>>
>>FUNCTION GetCompName
>>* Declare the API function
>>DECLARE INTEGER GetComputerName IN Win32API ;
>>   STRING  @cComputerNameBuffer, ;
>>   INTEGER @nLengthOfName
>>LOCAL cMyBuffer, nBufferLen, nResult, cReturnVal
>>*
>>*  Create a fixed-length buffer to hold result;  we'll examine the buffer length
>>*   after the call to see how long the name really is - under Win32, it shouldn't exceed 15 chars + null
>>*
>>cMyBuffer = SPACE(255)+CHR(0)
>>nBufferLen=256
>>*
>>*  Note how seriously I believe the values in the VC .h files!
>>*
>>nResult = GetComputerName(@cMyBuffer, @nBufferLen)
>>IF nResult = 1
>>   cReturnVal=STRTRAN(LEFT(cMyBuffer,nBufferLen),CHR(0),'')
>>ELSE
>>   cReturnVal = ''
>>ENDIF
>>RETURN cReturnVal
>>
>
>Sys(0) has worked for me quite well. Another thing I get from using it is the current user name if on network environment (which is 100% of the time). Can you post corresponding API (for getting user name that is)? TIA

Which user name? The name they're logged into the local machine as (e Windows Login) or the user name for a particular domain or server that the user is logged to? They don't have to be the same, and in some cases, multiple user names may be in use if multiple servers or domains are being referenced. The GetUserName() call should do the trick if you want the local ID:
DECLARE INTEGER GetUserName IN Win32API ;
   STRING  @cUserNameBuffer, ;
   INTEGER @nLengthOfName
You'll need to user WNetGetUser() to get how they're logged into other resources:
DECLARE INTEGER WNetGetUser IN Win32API ;
   STRING @cRemoteResourceName, ;
   STRING @cRemoteUserNameBuffer, ;
   INTEGER @nLengthOfUserName
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform