Slt tt l monde,
Voilà, j'ai tant cherché dans les FAQ et tutos C++, et je ne suis pas arrivé à trouver une fonction qui me renvoie l'utilisateur courant ainsi que le nom de la machine;
Est ce que qq'1 sait comment faire??
Merci
Slt tt l monde,
Voilà, j'ai tant cherché dans les FAQ et tutos C++, et je ne suis pas arrivé à trouver une fonction qui me renvoie l'utilisateur courant ainsi que le nom de la machine;
Est ce que qq'1 sait comment faire??
Merci
C vrai en fait il s'agit de windows XP
"gethostname" fonction qui fait partie des sockets.
Retourne le nom de la machine. Compatible Windows/Linux.
Regarde dans les variables d'environnement
POSIX tu veux dire ?Envoyé par Ti-R
Et je doute que cela réponde à sa question : IIRC, cela retourne des noms de machines.
Blog|FAQ C++|FAQ fclc++|FAQ Comeau|FAQ C++lite|FAQ BS|Bons livres sur le C++
Les MP ne sont pas une hotline. Je ne réponds à aucune question technique par le biais de ce média. Et de toutes façons, ma BAL sur dvpz est pleine...
The GetUserName function retrieves the user name of the current thread. This is the name of the user currently logged onto the system.
Windows 2000: Use the GetUserNameEx function to retrieve the user name in a specified format.
BOOL GetUserName(
LPTSTR lpBuffer, // name buffer
LPDWORD nSize // size of name buffer
);
Parameters
lpBuffer
[out] Pointer to the buffer to receive the null-terminated string containing the user's logon name. If this buffer is not large enough to contain the entire user name, the function fails. A buffer size of (UNLEN + 1) characters will hold the maximum length user name including the terminating null character. UNLEN is defined in Lmcons.h.
nSize
[in/out] Pointer to a DWORD variable that, on input, specifies the maximum size, in TCHARs, of the buffer specified by the lpBuffer parameter. If the function succeeds, the variable receives the number of characters copied to the buffer. If the buffer is not large enough, the function fails and the variable receives the required buffer size, in TCHARs, including the terminating null character.
Return Values
If the function succeeds, the return value is a nonzero value, and the variable pointed to by nSize contains the number of characters copied to the buffer specified by lpBuffer, including the terminating null character.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Je ne sais pas si la fonction est POSIXEnvoyé par Luc Hermitte
Cela ne répond pas à toute sa question mais en partie !Envoyé par nbeligh
Sous Windows elle renvoie bien le nom de l'ordinateur (je l'utilise)
Et en tapant "man gethostname" sous google il y a ce résultat
man gethostname
extrait
CONFORMITÉ
SVr4, 4.4BSD (Cette fonction est apparue en premier dans
4.2BSD). POSIX.1 ne définit pas ces fonctions, mais
ISO/IEC 9945-1:1990 les mentionne au paragraphe B.4.4.1.
Partager