I am attempting to create a program which writes the current username in text form (example John) to file on windows. I tried it through GetUserNameEx(NameDisplay, name, &size);
but the output value is
002CF514
I tried this:
#ifndef _UNICODE
#define _UNICODE
#define UNICODE
#endif
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#define SECURITY_WIN32
#include <Security.h>
#include <iostream>
#include <Lmcons.h>
#include <fstream>
#pragma comment(lib, "Secur32.lib")
using namespace std;
int main(void)
{
TCHAR name[UNLEN + 1];
DWORD size = UNLEN + 1;
GetUserNameEx(NameDisplay, name, &size);
ofstream File;
File.open("NAME.TXT", ios::app);
File << name;
File.close();
return 0;
}