Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define UNICODE
- #define _UNICODE
- //#define TESTING
- #include <windows.h>
- #include <wininet.h>
- #include <tlhelp32.h>
- #include <iostream>
- using namespace std;
- #pragma comment(lib,"ws2_32.lib")
- //ToDo: Special Dirs
- int QueryKey(HKEY hKey, LPTSTR Path, LPTSTR Value);
- struct SearchRegistry{
- LPTSTR Key;
- LPTSTR ValueName;
- };
- int main()
- {
- TCHAR ComputerName[512] = {0}, UserName[512] = {0}, CPUName[512] = {0},
- VendorIdentifier[512] = {0}, Country[512] = {0}, lpVolumeNameBuffer[512] = {0},
- lpFileSystemNameBuffer[512] = {0}, szDrives[512] = {0},
- lpProcessorName[512] = {0}, ProcessorRegistryPath[512] = {0},
- NETPath[MAX_PATH] = {0}, NetVersion[11]=TEXT("v0.0");
- char hostname[255], *IPAddress;
- DWORD dwComputerNameSize=512, dwUserNameSize=512, dwSize=512, dwType, dwTotal, dwHours, dwMinutes, dwDays,
- dwVolumeNameSize=512, dwVolumeSerialNumber, dwMaximumComponentLenght, dwFileSystemFlags,
- dwFileSystemNameSize=512, dwProcessorIndex=0, dwProcessorNameLength=512, dwNetPathSize = 512;
- HKEY hKey, hKey2;
- srand(GetTickCount());
- try
- {
- #if defined TESTING
- wcout << TEXT("OS:");
- #endif
- OSVERSIONINFOEX osVI = {0};
- osVI.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
- if (GetVersionEx((LPOSVERSIONINFO)&osVI))
- {
- if( osVI.dwMajorVersion==4 && osVI.dwMinorVersion == 0 )
- {
- if ( osVI.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
- {
- wcout << TEXT("95");
- }
- if ( osVI.dwPlatformId == VER_PLATFORM_WIN32_NT )
- {
- wcout << TEXT("NT");
- }
- }
- else if ( osVI.dwMajorVersion == 4 && osVI.dwMinorVersion == 10 )
- {
- wcout << TEXT("98");
- }
- else if ( osVI.dwMajorVersion == 4 && osVI.dwMinorVersion == 90 )
- {
- wcout << TEXT("ME");
- }
- else if ( osVI.dwMajorVersion == 5 && osVI.dwMinorVersion == 0 )
- {
- wcout << TEXT("2000");
- }
- else if ( osVI.dwMajorVersion == 5 && osVI.dwMinorVersion == 1 )
- {
- wcout << TEXT("XP");
- }
- else if ( osVI.dwMajorVersion == 5 && osVI.dwMinorVersion == 2 )
- {
- wcout << TEXT("2003");
- }
- else if ( osVI.dwMajorVersion == 6 && osVI.dwMinorVersion == 0 )
- {
- wcout << TEXT("Vista");
- }
- else if ( osVI.dwMajorVersion == 6 && osVI.dwMinorVersion == 1 )
- {
- wcout << TEXT("7");
- }
- else
- {
- wcout <<osVI.dwMajorVersion << "." << osVI.dwMinorVersion;
- }
- }
- wcout << TEXT(" ") << osVI.szCSDVersion
- << TEXT(" (") << osVI.dwMajorVersion << TEXT(".") << osVI.dwMinorVersion << TEXT(")")
- << TEXT(" SP") << osVI.wServicePackMajor << TEXT(".") << osVI.wServicePackMinor
- << TEXT(" PlatformId:") << osVI.dwPlatformId
- << TEXT(" Build:") << osVI.dwBuildNumber;
- #if defined TESTING
- wcout << endl << endl;
- #endif
- if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\.NETFramework"),
- 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL) == ERROR_SUCCESS)
- {
- if(RegQueryValueExW(hKey, TEXT("InstallRoot"), NULL, 0, (LPBYTE)NETPath,
- &dwNetPathSize) == ERROR_SUCCESS)
- {
- WIN32_FIND_DATA FoundFile;
- HANDLE FileHandle;
- //wcout << NETPath << endl;
- lstrcat(NETPath, TEXT("\\v*.*"));
- FileHandle = FindFirstFile(NETPath, &FoundFile);
- do
- {
- //FoundFile.cFileName[4] = 0;
- //wcout << FoundFile.cFileName << endl;
- if(lstrcmp(FoundFile.cFileName, NetVersion))//FoundFile.cFileName[1] > NetVersion[1] || FoundFile.cFileName[3] > NetVersion[3])
- {
- lstrcpy(NetVersion, FoundFile.cFileName);
- }
- }while(FindNextFile(FileHandle, &FoundFile));
- FindClose(FileHandle);
- }
- RegCloseKey(hKey);
- }
- #if defined TESTING
- wcout << TEXT("Installed .NET Version: ");
- #else
- wcout << TEXT(";");
- #endif
- wcout << NetVersion;
- #if defined TESTING
- wcout << endl << endl;
- #endif
- #if defined TESTING
- wcout << TEXT("Uptime:") << endl;
- #else
- wcout << TEXT(";");
- #endif
- /*
- UPTIME
- */
- dwTotal = GetTickCount() / 1000;
- dwDays = dwTotal / 86400;
- dwHours = (dwTotal % 86400) / 3600;
- dwMinutes = ((dwTotal % 86400) % 3600) / 60;
- wcout << TEXT("Days: ") << dwDays
- << TEXT("\tHours: ") << dwHours
- << TEXT("\tMin: ") << dwMinutes;
- #if defined TESTING
- wcout << endl << endl;
- #endif
- SYSTEMTIME lpSystemTime;
- #if defined TESTING
- wcout << TEXT("UTC Time:") << endl;
- #else
- wcout << TEXT(";");
- #endif
- /*
- DATETIME
- */
- GetSystemTime(&lpSystemTime);
- wcout << lpSystemTime.wDay << TEXT(".") << lpSystemTime.wMonth << TEXT(".") << lpSystemTime.wYear
- << TEXT(" ") << lpSystemTime.wHour
- << TEXT(":") << lpSystemTime.wMinute << TEXT(":") <<lpSystemTime.wSecond;
- #if defined TESTING
- wcout << endl << endl;
- #else
- wcout << TEXT(";");
- #endif
- /*
- INTERNET CONNECTION TYPE
- */
- DWORD dwConnectionType;
- if(InternetGetConnectedState(&dwConnectionType, 0))
- {
- wcout << dwConnectionType;
- }
- else
- wcout << TEXT("Error:") << GetLastError();
- #if defined TESTING
- wcout << endl << endl;
- #else
- wcout << TEXT(";");
- #endif
- GetComputerName(ComputerName, &dwComputerNameSize);
- GetUserName(UserName, &dwUserNameSize);
- GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SLANGUAGE, Country, 512);
- wcout << TEXT("PCName: ") << ComputerName
- << TEXT("\tUser: ") << UserName
- << TEXT("\tLanguage: ") << Country;
- #if defined TESTING
- wcout << endl << endl << TEXT("Drives:") << endl;
- #else
- wcout << TEXT(";");
- #endif
- /*
- DRIVE INFO
- */
- if(GetLogicalDriveStrings( MAX_PATH, szDrives ))
- {
- LPTSTR lptszOneDrive = szDrives;
- while(*lptszOneDrive)
- {
- if(lptszOneDrive[0] == 'A')
- {
- lptszOneDrive += lstrlen( lptszOneDrive ) + 1;
- continue;
- }
- if(GetVolumeInformation(lptszOneDrive, lpVolumeNameBuffer, dwVolumeNameSize, &dwVolumeSerialNumber,
- &dwMaximumComponentLenght, &dwFileSystemFlags, lpFileSystemNameBuffer, dwFileSystemNameSize))
- {
- wcout << lptszOneDrive << TEXT("\t");
- wcout << TEXT("\tName:") <<lpVolumeNameBuffer
- //<< TEXT("\tSerial:") <<dwVolumeSerialNumber<<endl
- //<< TEXT("\tMaximal Filename length:") <<dwMaximumComponentLenght
- << TEXT("\tFileSystem:") <<lpFileSystemNameBuffer
- << TEXT("\t");
- }
- #if defined TESTING
- wcout << endl;
- #endif
- lptszOneDrive += lstrlen(lptszOneDrive) + 1;
- }
- }
- #if defined TESTING
- wcout <<endl;
- wcout << TEXT("CPU:") << endl;
- #else
- wcout << TEXT(";");
- #endif
- /*
- CPU
- */
- RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\"),
- 0, 0, REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &hKey, 0);
- if(hKey)
- {
- while(RegEnumKeyEx(hKey, dwProcessorIndex, lpProcessorName,
- &dwProcessorNameLength, 0, 0, 0, 0) != ERROR_NO_MORE_ITEMS)
- {
- wcout << TEXT("\tCPU:") << lpProcessorName;
- wsprintf(ProcessorRegistryPath, TEXT("%s\\%s"),
- TEXT("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\"), lpProcessorName);
- RegCreateKeyEx(HKEY_LOCAL_MACHINE, ProcessorRegistryPath, 0, 0, REG_OPTION_NON_VOLATILE,
- KEY_READ, NULL, &hKey2, 0);
- if(RegQueryValueEx(hKey2, TEXT("VendorIdentifier"), NULL, &dwType,
- (LPBYTE)VendorIdentifier, &dwSize)==ERROR_SUCCESS && strlen((char*)VendorIdentifier))
- {
- wcout << TEXT("\tBy: ") << VendorIdentifier;
- }
- dwSize = 512;
- if(RegQueryValueEx(hKey2, TEXT("ProcessorNameString"), NULL, &dwType,
- (LPBYTE)CPUName, &dwSize)==ERROR_SUCCESS && strlen((char*)CPUName))
- {
- wcout << TEXT("\tName: ") << CPUName;
- }
- dwProcessorIndex++;
- dwProcessorNameLength = 512;
- }
- }
- RegCloseKey(hKey);
- RegCloseKey(hKey2);
- #if defined TESTING
- wcout << endl << endl;
- wcout << TEXT("Local IP:") << endl;
- #else
- wcout << TEXT(";");
- #endif
- /*
- LOCAL IPs
- */
- PHOSTENT hostinfo;
- WSADATA wsadata;
- WSAStartup(MAKEWORD(2,2), &wsadata);
- if(gethostname(hostname, sizeof(hostname)) == 0)
- {
- if((hostinfo = gethostbyname(hostname)) != NULL)
- {
- while(*hostinfo->h_addr_list)
- {
- IPAddress = (char*)inet_ntoa ((*(struct in_addr *)*hostinfo->h_addr_list));
- cout << IPAddress;
- wcout << TEXT(",");
- *hostinfo->h_addr_list++;
- }
- }
- }
- WSACleanup();
- #if defined TESTING
- wcout << endl;
- #endif
- /*
- RAM INFO
- */
- MEMORYSTATUS memstat;
- GlobalMemoryStatus(&memstat);
- #if defined TESTING
- wcout << TEXT("Memory:") << endl;
- #else
- wcout << TEXT(";");
- #endif
- wcout << memstat.dwTotalPhys/(1024 * 1024) << TEXT("mb")
- << TEXT("\tIn Use:") << memstat.dwMemoryLoad << TEXT("%");
- #if defined TESTING
- wcout << endl << endl;
- /*#else
- wcout << TEXT(";");*/
- #endif
- /*
- INSTALLED SOFTWARE
- */
- HKEY hTestKey;
- SearchRegistry Cool[] =
- {
- //{TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths"), TEXT("")},
- {TEXT("SOFTWARE\\"), TEXT("")},
- 0
- };
- for(int i = 0; Cool[i].Key; i++)
- {
- HKEY HKeys[] = {HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER, 0};
- for(int j = 0; HKeys[j]; j++)
- {
- wcout << TEXT(";Enumerating ") << HKeys[j] << TEXT("\\") << Cool[i].Key << endl;
- if(RegOpenKeyEx(HKeys[j], Cool[i].Key, 0, KEY_READ, &hTestKey) == ERROR_SUCCESS)
- {
- QueryKey(hTestKey, Cool[i].Key, Cool[i].ValueName, Cool[i].WTE);
- RegCloseKey(hTestKey);
- }
- }
- }
- #if defined TESTING
- wcout << endl << endl;
- #endif
- /*
- PRCESSLIST
- */
- HANDLE hProcessSnap;
- PROCESSENTRY32 pe32;
- #if defined TESTING
- wcout << TEXT("Process list:") << endl;
- #else
- wcout << TEXT(";");
- #endif
- hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
- pe32.dwSize = sizeof(PROCESSENTRY32);
- if (Process32First(hProcessSnap, &pe32))
- {
- //Loop Through Processnames In Hunt Of The One We Are Looking For
- do
- {
- wcout << pe32.szExeFile << TEXT(",");
- }while(Process32Next(hProcessSnap, &pe32));
- }
- CloseHandle(hProcessSnap);
- wcout << TEXT(";");
- /*
- SPEEDTEST
- */
- DWORD dwStartTime = 0, dwEndTime = 0, dwFileSize = 0, dwDownSpeed = 0, dwUDTFReturn = 0;
- TCHAR path[MAX_PATH] = {0};
- HANDLE hFile;
- LPTSTR szBigFiles[] =
- {
- TEXT("http://download.thinkbroadband.com/10MB.zip"),
- TEXT("http://google.com"),
- 0
- };
- /*GetTempPath(MAX_PATH - lstrlen(TEXT("speedtest.bin")), path);
- lstrcat(path, TEXT("speedtest.bin"));*/
- LPTSTR pLastFile = szBigFiles[3], FileToUse;
- //Download 2 files in hope to get a more accurate estimate
- for(int k = 0; k < 2; k++)
- {
- do
- {
- FileToUse = szBigFiles[rand() % 6];
- }while(FileToUse == pLastFile);
- pLastFile = FileToUse;
- dwStartTime = GetTickCount();
- if((dwUDTFReturn = URLDownloadToCacheFile(0, FileToUse, path, MAX_PATH, 0, 0)) != S_OK)
- {
- wcout << GetLastError() << TEXT(":") << dwUDTFReturn << endl;
- continue;
- }
- dwEndTime = GetTickCount();
- wcout << path << endl;
- hFile = CreateFile(path, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
- if(hFile == INVALID_HANDLE_VALUE)
- {
- wcout << GetLastError() << endl;
- continue;
- }
- dwFileSize = GetFileSize(hFile, 0) / (1024*1024);
- CloseHandle(hFile);
- DeleteFile(path);
- dwDownSpeed = (dwEndTime - dwStartTime) / 1000;
- wcout << FileToUse << TEXT(" (") << dwFileSize << TEXT("mb) downloaded in ")
- << dwDownSpeed << TEXT("sec! ");
- }
- wcout << TEXT(";");
- }
- catch(...)
- {
- wcout << TEXT("An exception occured. Meaning I suck at coding,") << endl;
- }
- */
- return 0;
- }
- #define MAX_KEY_LENGTH 255
- #define MAX_VALUE_NAME 512
- int QueryKey(HKEY hKey, LPTSTR Path, LPTSTR ValueName)
- {
- TCHAR achKey[MAX_KEY_LENGTH]; // buffer for subkey name
- DWORD cbName; // size of name string
- TCHAR achClass[MAX_PATH] = TEXT(""); // buffer for class name
- DWORD cchClassName = MAX_PATH; // size of class string
- DWORD cSubKeys=0; // number of subkeys
- DWORD cbMaxSubKey; // longest subkey size
- DWORD cchMaxClass; // longest class string
- DWORD cValues; // number of values for key
- DWORD cchMaxValue; // longest value name
- DWORD cbMaxValueData; // longest value data
- FILETIME ftLastWriteTime; // last write time
- DWORD i, retCode;
- TCHAR achValue[MAX_VALUE_NAME];
- DWORD cchValue = MAX_VALUE_NAME;
- TCHAR achValue_[512];
- DWORD cchValue_ = 512;
- // Get the class name and the value count.
- retCode = RegQueryInfoKey(
- hKey, // key handle
- achClass, // buffer for class name
- &cchClassName, // size of class string
- NULL, // reserved
- &cSubKeys, // number of subkeys
- &cbMaxSubKey, // longest subkey size
- &cchMaxClass, // longest class string
- &cValues, // number of values for this key
- &cchMaxValue, // longest value name
- &cbMaxValueData, // longest value data
- 0, // security descriptor
- 0); // last write time
- if (cValues)
- {
- //printf( "\nNumber of values: %d\n", cValues);
- // wcout << TEXT("|") << cValues << TEXT("|");
- for (i=0, retCode=ERROR_SUCCESS; i<cValues; i++)
- {
- cchValue_ = 512; cchValue = MAX_VALUE_NAME;
- //achValue[0] = '\0'; achValue_[0] = '\0';
- retCode = RegEnumValue(hKey, i,
- achValue,
- &cchValue,
- NULL,
- NULL,
- (LPBYTE)achValue_,
- &cchValue_);
- if (retCode == ERROR_SUCCESS )
- {
- wcout << achValue << TEXT(" -> ") << achValue_;
- }
- wcout << TEXT(",");
- }
- }
- END:
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement