Advertisement
ASP_Volume2 Validation/ Processing #40855

GetComputerInfo

This code allows you to get windows version information, current windows User Name, and Computer Name (utilizing the windows API)... {For people searching: USERNAME COMPUTERNAME WINDOWSVERSION GETVERSION GETVERSIONEX GETUSERNAME GETCOMPUTERNAME} Note: Updated this old code to be actual Win32 code and added the OS version stuff.

AI

Yapay Zeka Özeti: 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.

Kaynak Kod
original-source
// Header for windows API
#include <windows.h>
// Header for various defines
#include <lmcons.h>
// Entry function for windows projects
int WINAPI WinMain(HINSTANCE hCur, HINSTANCE hPrev, LPSTR sCmd, int nShow)
{
	// Variable for output buffer
	TCHAR sMsg[1024];
	// Variable for username string
	TCHAR sUserName[UNLEN + 1];
	// Variable to computername string
	TCHAR sCompName[MAX_COMPUTERNAME_LENGTH + 1];
	// Variable for username length
  DWORD dwUserName = sizeof(sUserName);
  // Variable for compname length
  DWORD dwCompName = sizeof(sCompName);
	// Variable for os version structure
	OSVERSIONINFO osver;
	osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
 
	// Get OS Version info
	GetVersionEx(&osver);
	// Get User Name
  GetUserName(sUserName, &dwUserName);
  // Get Computer Name
  GetComputerName(sCompName, &dwCompName);
  
	// Copy to message buffer
	wsprintf(sMsg, "User %s is currently logged onto computer %s running Windows version %d.%d build %d %s",
		sUserName,
		sCompName, 
		osver.dwMajorVersion, 
		osver.dwMinorVersion, 
		osver.dwBuildNumber,
		osver.szCSDVersion
		);
	// Display information
	MessageBox(NULL, sMsg, "Computer Information", MB_OK | MB_ICONINFORMATION);
  // End instance
  return (0);
}
Orijinal Yorumlar (3)
Wayback Machine'den kurtarıldı