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
AI 요약: 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.
소스 코드
// 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;
}
원본 댓글 (3)
Wayback Machine에서 복구됨