(C++) Detecting Hostname, Username by Thomas Roccia
Created the Thursday 10 September 2020. Updated 3 years, 3 months ago.
Code
#include <iostream>
#include <windows.h>
int WINAPI WinMain ( HINSTANCE, HINSTANCE, LPSTR, int )
{
char ComputerName [MAX_COMPUTERNAME_LENGTH + 1];
DWORD cbComputerName = sizeof ( ComputerName );
if ( GetComputerName ( ComputerName, &cbComputerName ))
{
MessageBox ( NULL, ComputerName, "Computer Name:", MB_OK | MB_ICONINFORMATION );
}
}