//Get some computer info example by DreamVB

#include <iostream>
#include <Windows.h>
#include <time.h>

using namespace std;
using std::cout;
using std::endl;

string GetDateTimeNow();

enum MyInfo{
	ICOMPUTER = 0,
	IOS = 2,
	IUSER = 3,
	IWINDIR = 4,
	ITEMP = 5,
	ISYSDIR = 6,
	INOW = 7,
	ICPU = 8
};

string GetDateTimeNow(){
	string s0 = "";
	char sNow[80];
	time_t curtime = time(0);
	struct tm *now = localtime(&curtime);

	//Return date and time.
	itoa(now->tm_hour,sNow,10);
	s0 = sNow;
	s0 += ":";
	itoa(now->tm_min,sNow,10);
	s0 += sNow;
	s0 += ":";
	itoa(now->tm_sec,sNow,10);
	s0 += sNow;
	s0 += " ";
	//
	itoa(now->tm_mday,sNow,10);
	s0 += sNow;
	s0 += "/";
	itoa(now->tm_mday,sNow,10);
	s0 += sNow;
	s0 += "/";
	itoa(now->tm_year+1900,sNow,10);
	s0 += sNow;
	//Clear up
	memset(sNow,0,sizeof(sNow));
	return s0;
}

string GetMyInfo(MyInfo option = ICOMPUTER){
	TCHAR Ret[80];
	wstring test = L"";
	DWORD size = sizeof(Ret) / sizeof(Ret[0]);

	switch(option){
		case ICOMPUTER:
			//Get computer name
			GetComputerName(Ret,&size);
			break;
		case IOS:
			return getenv("OS");
		case IUSER:
			//Get username
			GetUserName(Ret,&size);
			break;
		case IWINDIR:
			GetWindowsDirectory(Ret,size);
			break;
		case ITEMP:
			GetTempPath(size,Ret);
			break;
		case ISYSDIR:
			GetSystemDirectory(Ret,size);
			break;
		case INOW:
			return GetDateTimeNow();
		case ICPU:
			return getenv("PROCESSOR_IDENTIFIER");
	}

	//Covert Ret to wide string
	test = wstring(&Ret[0]);
	//clear
	memset(Ret,0,size);
	//Return string from wide string.
	return string(test.begin(),test.end());	
}

int main(){

	cout << "Your Computer Name is      : " << GetMyInfo(ICOMPUTER).c_str() << endl;
	cout << "Your Operateing System is  : " << GetMyInfo(IOS).c_str() << endl;
	cout << "Your user name is          : " << GetMyInfo(IUSER).c_str() << endl;
	cout << "Your Windows folder is     : " << GetMyInfo(IWINDIR).c_str() << endl;
	cout << "Your Temp folder is        : " << GetMyInfo(ITEMP).c_str() << endl;
	cout << "Your System folder is      : " << GetMyInfo(ISYSDIR).c_str() << endl;
	cout << "Time and Date              : " << GetMyInfo(INOW).c_str() << endl;
	cout << "Your CPU is                : " << GetMyInfo(ICPU).c_str() << endl;
	system("pause");
	return 1;
}