GetUserName und Windows XP SP3



GetUserName und Windows XP SP3

Jac, 03.05.2008 16:48: Wie es mir scheint, existiert die API "GetUserName" nicht mehr im SP3 von Windows XP. Hat jemand schon Erfahrung mit GetUserNameEx? Ich quäl mich momentan mit den Parametern rum. Und weiss jemand, wann GetUserNameEx eingeführt wurde? Dazu finde ich nämlich irgendwie keine klare Info.
Jac


Dieter Z., 03.05.2008 18:39: GetUserNameEx Function
Retrieves the name of the user or other security principal associated with the calling thread. You can specify the format of the returned name.
If the thread is impersonating a client, GetUserNameEx returns the name of the client.
Syntax
BOOLEAN WINAPI GetUserNameEx(
__in EXTENDED_NAME_FORMAT NameFormat,
__out LPTSTR lpNameBuffer,
__inout PULONG lpnSize
);
Parameters
NameFormat
The format of the name. This parameter is a value from the EXTENDED_NAME_FORMAT enumeration type. It cannot be NameUnknown.
lpNameBuffer
A pointer to a buffer that receives the name in the specified format. The buffer must include space for the terminating null character.
lpnSize
On input, this variable specifies the size of the lpNameBuffer buffer, in TCHARs. If the function is successful, the variable receives the number of TCHARs copied to the buffer, not including the terminating null character.
If lpNameBuffer is too small, the function fails and GetLastError returns ERROR_MORE_DATA. This parameter receives the required buffer size, in Unicode characters (whether or not Unicode is being used), including the terminating null character.
If this parameter is greater than 32767, the function fails and GetLastError returns ERROR_MORE_DATA.
Return Value
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get extended error information, call GetLastError. Possible values include the following.
Ist so bei Microsoft beschrieben du findest dort auch die Beschreibung für den ersten Parameter
Zu finden ist die Funktion in der secur32.dll,
Gruss
Dieter


Jac, 03.05.2008 19:48: Hm, das hab ich ja auch schon herausgefunden, aber meine Programmierversuche enden im ExceptionFault.
Trotzdem danke,
Jac


Jac, 03.05.2008 23:24: Jetzt habe ich versucht mich auf "LookupAccountNameA" zu verlegen, weil das schon ab Windows NT 3.5 existiert, aber das kriege ich auch nicht zum Laufen...


Jörg Sellmeyer, 04.05.2008 15:01: Funktioniert das hier auch nicht mehr:?

print GetEnv$("UserName")
WaitInput
Such mal in der Liste nach "GetEnvVars$"


Dieter Z., 04.05.2008 17:41: Hallo Jac,
so gehts bei mir, es wird der Computername und der Username angezeigt

Def GetUserNameEx(3) ! "secur32","GetUserNameExA"
Def GetLastError(0) ! "kernel32","GetLastError"
cls
declare un#
var size& = 100
dim un#,100
print GetUserNameEx(2,un#,addr(size&))+" "
Print size&
Print Getlasterror()
print string$(un#,0)
dispose un#
waitinput
der erste Parameter: NameSamCompatible = 2,
Gruss
Dieter


Jac, 04.05.2008 19:00: Danke euch beiden. Beides funktioniert. Auf die Idee mit Systemvariablen bin ich noch nicht gekommen, weil ich mit denen noch nicht gearbeitet habe. Keine Ahnung, ob die immer gesetzt ist.
Die zweite Variante gefällt mir etwas besser.
Jac


Artur D., 05.05.2008 12:16: Da es System-Variablen sind, sind diese auch immer gesetzt.
Diese sind global unter Profan verfügbar und dienen allein dem Zweck die System-Informationen auszugeben.
Das erleichtert vieles ungemein!


Jörg Sellmeyer, 05.05.2008 14:14:   Zitat von ""Jac"": „Die zweite Variante gefällt mir etwas besser.
Jac

Wahrscheinlich, weil sie komplizierter und mehr nach "programmieren" aussieht

Aber warum einfach, wenn's auch umständlich geht...


Jac, 05.05.2008 17:46: Stimmt. Aber wenn die Variablen IMMER gesetzt sind, werde ich doch die andere Variante nehmen. In der Hoffnung, dass es nicht in Windows 7 rausfliegt.
Jac


Dies ist die Offlinevariante vom Thread [GetUserName und Windows XP SP3].

Valid CSS!

©2006 XProfan.Com