Hello Hi all! Ok getting straight to the point, Below is the code I was able to formulate to get information about the PC I'm using, I want to modify this code so I can get the information of all the workstations that are connected within the domain and print them out like the example. Question is: how would I modify it to connect to a computer and get the info for print out? The idea I have is creating a server & client app, were the client app sends the info to the server app (Yes I will have to manually install the app and put it on start up to all client pc's). Is there another easier way I can do this?
#include <windows.h>
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
//max character length for all information
#define MAX_LENGTH 50
int main(void)
{
//character varibles to hold names and name size
char dmnNameBuf[MAX_LENGTH];
char usrNameBuf[MAX_LENGTH];
std::string serialTag;
std::string pcModel;
DWORD pcNameBufSize = sizeof dmnNameBuf-1;
DWORD usrNameBufSize = sizeof usrNameBuf-1;
//Files for data manipulation, input and output files
std::ifstream name("name.txt");
std::ifstream ser("ser.txt");
//std::ofstream outfile("out.txt");
//Check if the computer name can be retrived if yes continue to get more info
if (GetComputerNameA(dmnNameBuf, &pcNameBufSize) == true)
{
//Serial number, user name, and the computer model from the bios
GetUserNameA(usrNameBuf, &usrNameBufSize);
std::getline(ser, serialTag), std::getline(name, pcModel); //Dummy containing the first line.
std::getline(ser, serialTag); //Actual lines containing the serial nubmer
std::getline(name, pcModel); //Actual line containing the computer model
//Ouput the informaiton to the console
std::cout << " User Name\t " << usrNameBuf << std::endl;
std::cout << " Domain Name\t " << dmnNameBuf << std::endl;
std::cout << " Computer Model\t " << pcModel << std::endl;
std::cout << " Serial/Tag\t " << serialTag << std::endl;
}
std::cin.get();
return 0;
}
Output