Advertisement
2002VB Validation/ Processing #25051

GetUserName

This code allows you to get the current windows User Name and Computer Name (utilizing the windows API)... {For people searching: USERNAME COMPUTERNAME}

AI

KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Quellcode
original-source
// Information
// --------
// Program:		GetUserCompName
// Description:	Displays the computer name and current user name on a windows system
// Programmer:	Merlin Corey
// LastEdit:	12 December 2001
// --------
// Headers
// --------
// Header for input and output functions
#include <iostream.h>
// Header for Win32 API
#include <windows.h>
// Main Function
// --------
int main()
{
 // Variable for user name
 char chrUserName[100];
 // Variable for computer name
 char chrCompName[100];
 // Variable for username length
 DWORD dwUserName = sizeof(chrUserName);
 // Variable for compname length
 DWORD dwCompName = sizeof(chrCompName);
 // Get User Name
 GetUserName(chrUserName, &dwUserName);
 // Get Computer Name
 GetComputerName(chrCompName, &dwCompName);
	
 // Display Information
 cout << "User " << chrUserName << " is currently logged onto computer " << chrCompName << ".\n\n";
 // Return control to OS
 return 0;
}
Originalkommentare (3)
Wiederhergestellt von der Wayback Machine