c++ - How can I get the username of the person executing my program? -
How can I get the user name of the process owner (users who is executing my program) in C ++ ?
Example:
windows
Code> Four UserName [UNLEN + 1]; DWORD user_name_size = sizeof (user_name); If (GetUserName (user_name, and user_name_size)) cout & lt; & Lt; "Your username is:" & lt; & Lt; User_name & lt; & Lt; Endl;
The getpwuid () function will search the user database for an entry with the UID.
.Use
getuid
to get the user ID.
Comments
Post a Comment