[C Win32] Comment récupérer le nom d'utilisateur ?

Comment récupérer le nom d'utilisateur ? [C Win32] - C++ - Programmation

Marsh Posté le 30-09-2002 à 16:57:38    

Je voudrais connaitre la/les fonction(s) permettant de récupérer le nom de l'utilisateur actuellement logué sur un poste NT/2000.
 
Y'a un moyen ?

Reply

Marsh Posté le 30-09-2002 à 16:57:38   

Reply

Marsh Posté le 30-09-2002 à 17:05:08    

GetUserName


---------------
mes programmes ·· les voitures dans les films ·· apprenez à écrire
Reply

Marsh Posté le 01-10-2002 à 08:02:30    

La seule fonction GetUserName que j'ai trouvé est celle ci:
 

CDaoWorkspace::GetUserName
CString GetUserName( );
throw( CDaoException, CMemoryException );
 
Return Value
 
A CString that represents the owner of the workspace object.  
 
Remarks
 
Call this member function to obtain the name of the owner of the workspace.  
 
To get or set the permissions for the workspace owner, call DAO directly to check the Permissions property setting; this determines what permissions that user has. To work with permissions, you need a SYSTEM.MDA file.  
 
For more information about workspaces, see the articleDAO Workspace. For information about calling DAO directly, see Technical Note 54. For related information, see the topic "UserName Property" in DAO Help.
 
CDaoWorkspace Overview |  Class Members |  Hierarchy Chart
 
See Also   CDaoWorkspace::SetDefaultUser


 
Y'a pas moyen de le faire sans utiliser de MFC ?

Reply

Marsh Posté le 01-10-2002 à 08:54:34    

Et msdn.microsoft.ocm ça sert à quoi ?
 
http://msdn.microsoft.com/library/ [...] nameex.asp
 


Platform SDK: Windows System Information
GetUserNameEx
 
 
The 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.
 
 
 
 
BOOLEAN GetUserNameEx(
  EXTENDED_NAME_FORMAT NameFormat,
  LPTSTR lpNameBuffer,
  PULONG nSize
);
 
 
Parameters
 
NameFormat
[in] Format of the name. This parameter is a value from the EXTENDED_NAME_FORMAT enumeration type. It cannot be NameUnknown.
lpNameBuffer
[out] Pointer to a buffer that receives the name in the specified format. The buffer must include space for the terminating null character.
nSize
[in, out] 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, including the terminating null character.
 
 
 
Return Values
 
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.
 
If the user name is not available in the specified format, the error is ERROR_NONE_MAPPED. If the domain controller is not available to perform the lookup, the error is ERROR_NO_SUCH_DOMAIN.
 
Requirements
 
Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Unsupported.
Unicode: Implemented as Unicode and ANSI versions.
Header: Declared in Secext.h; include Security.h.
Library: Use Secur32.lib.
 
See Also
 
System Information Overview, System Information Functions, EXTENDED_NAME_FORMAT, GetUserName
 


---------------
Le site de l'année :D (XHTML 1.0 strict) : http://darkoli.free.fr/index.html
Reply

Marsh Posté le 01-10-2002 à 09:02:44    

Desolé mais ce n'était pas dans la MSDN qu'on m'a fournis sur CD.
Je ne pense pas à utiliser la version en ligne.
 
Merci du coup de main  :hello:

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed