Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do get a user login name from Windows
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00501724
Message ID:
00501935
Vues:
23
>Hi Stuart.
>
>>I need to be able to find the user name a person has used to login onto Windows 2000 Server from within a FoxPro application.
>
>Here's what I use:
local lcName, ;
>    lnSize, ;
>    lcUser, ;
>    lnStatus
>
>* Initialize the variables we need and declare the Windows function.
>
>lcName = chr(0)
>lnSize = 64
>lcUser = replicate(lcName, lnSize)
>declare integer WNetGetUser in Win32API ;
>    string @cName, string @cUser, integer @nBufferSize
>
>* Call the function and return the result.
>
>lnStatus = WNetGetUser(@lcName, @lcUser, @lnSize)
>lcUser   = iif(lnStatus = 0, upper(left(lcUser, at(chr(0), lcUser) - 1)), '')
>return lcUser
Doug,

If the Windows Script Host is available
oNet = CREATEOBJECT("WScript.Network")
? oNet.UserName
George

Ubi caritas et amor, deus ibi est
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform