Home > Software engineering >  retrive username and domain with GetUserNameExA
retrive username and domain with GetUserNameExA

Time:07-10

I am trying to get username and domain with GetUserNameExA function

this is my code

 #include <windows.h>
#include <Lmcons.h>
#include <iostream>
using namespace std;

#include <windows.h>
#include <Lmcons.h>
#include <Security.h>
#include <secext.h>


DWORD main()
{
    
        CHAR  *username = [200];
        DWORD dwSize = 199;
        memset(username, 0x00, 200);
        GetUserNameExA(NameSamCompatible, username, &dwSize);
        wcout << L"Hello, " << NameSamCompatible << L"!\n";
    

}

but keep getting an error that you need to declare an identifer

can you plz help me to figure it out?

CodePudding user response:

CHAR  *username = [200];

should be this

char username[200];

And this

wcout << L"Hello, " << NameSamCompatible << L"!\n";

should be this

cout << "Hello, " << username << "!\n";
  • Related