Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get user name from network
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00275384
Message ID:
00275426
Vues:
22
>>>I got the following info from the universal thread but it doesn't seem to work. I am not that familiar with API calls and would appreciate any help. It's a Novell network if that makes any difference.
>>>
>>>DECLARE INTEGER GetUserName IN WIN32API String @, Integer @
>>>
>>>LOCAL lcUser
>>>lcUser=SPACE(20)
>>>GetUserName(@lcUser,20) && try 30 here
>>>lcUser=UPPER(STRTRAN(lcUser,CHR(0),''))
>>>
>>>It bombs on GetUserName(@lcUser,20) Say unrecognized command verb. What am I doing incorrectly,
>>
>>Perhaps 20 isn't enough bytes, I use exactly the same with 30 and it works. Anyway, we just had a thread on this, and it turns out that in any version of vfp SYS(0) will work just fine. Just cut out the part of the sys(0) result that you don't want (the machine name).
>
>Hi Bruce,
>
>If enough space isn't allocated for the buffer the function would fail, but the it wouldn't cause VFP to crash. The problem here is that the function expects a pointer to the memory so that it can be changed. That's what's achieved when you pass by reference. In the example, the value was passed by value, and the OS is expecting a pointer to a location. Therefore, not only will the function fail, but, in all likelihood, crash VFP.

I know you know a lot more about this than I, but I've been using it the way I noted for several years without a problem under Win95. Perhaps this is an NT problem?
The Anonymous Bureaucrat,
and frankly, quite content not to be
a member of either major US political party.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform