Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

How to: Retrieve the Current Username (C++/CLI)

The following code example demonstrates the retrieval of the current user name (the name of the user logged into Windows). The name is stored in the UserName string, which is defined in the Environment namespace.

// username.cpp
// compile with: /clr
using namespace System;

int main() 
{
   Console::WriteLine("\nCurrent user: {0}", Environment::UserName);
   return 0;
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.