Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I obtain the user name?
Message
 
À
18/05/2006 14:57:21
Vernon Chambers
New York City Transit
New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Novell 6.x
Divers
Thread ID:
01123025
Message ID:
01123383
Vues:
17
This message has been marked as the solution to the initial question of the thread.
>I used the SYS(0) and it returned the username... all good. However, the username (in this case) is the login userid. Is there a way to return the 'FULLNAME'?

Here is an API solution:
FUNCTION UserFullName(lcUserName)

LOCAL lcUserName, lnAddress, lcFullName
LOCAL lcPtr2, lnPtr2

DECLARE Long NetUserGetInfo IN netapi32 String, String, Long, Long@
DECLARE Long NetApiBufferFree IN netapi32 Long

lcUserName = IIF(EMPTY(lcUserName), GETENV("username"), lcUserName)
lnAddress = 0
lcFullName = ""

IF NetUserGetInfo(NULL, STRCONV(lcUserName+CHR(0),5), 10, @lnAddress) = 0
   lcPtr2 = SYS(2600, lnAddress+12, 4)
   lnPtr2 = BITXOR(CTOBIN(CHRTRAN("ABCD","DCBA",lcPtr2)),0x80000000)
   lcFullName = SYS(2600, lnPtr2, 512)
   lcFullName = STRCONV(lcFullName,6)
   IF CHR(0) $ lcFullName
      lcFullName = LEFT(lcFullName, AT(CHR(0), lcFullName)-1)
   ENDIF

   NetApiBufferFree(lnAddress)
ENDIF

RETURN lcFullName
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform