19 #define DIRECTINPUT_VERSION 0x0700
29 void Print(
const char* fmt, ...);
31 static int cpu_class=-1;
32 static int cpu_speed=-1;
33 static int platform=-1;
34 static int dx_version=-1;
35 static int total_ram=-1;
37 static OSVERSIONINFO os_ver = {
sizeof(OSVERSIONINFO) };
38 static SYSTEM_INFO cpu_info;
39 static MEMORYSTATUS mem_info = {
sizeof(MEMORYSTATUS) };
46 static char desc[256];
48 static const char* cpu_names[] = {
60 static const char* os_names[] = {
74 if (cpu_index < 0) cpu_index = 0;
75 else if (cpu_index > 8) cpu_index = 8;
78 if (os_index < 0) os_index = 0;
80 sprintf_s(desc,
"%s %d MHz %d MB RAM %s",
91 static void DescribeCpuMake();
92 static void DescribeOwner95();
93 static void DescribeOwnerNT();
94 static void DescribeDrivers95(
const char* sType);
95 static void DescribeDriversNT(
const char* sType);
96 static void DescribeDriverVersion(
const char* file);
97 static void DescribeDXVersion(
const char* component);
102 static double SpinWait(
double target_time)
104 double actual_time = 0;
110 QueryPerformanceFrequency(&ifreq);
111 double freq = (double) ifreq.QuadPart;
113 QueryPerformanceCounter(&cnt1);
116 QueryPerformanceCounter(&cnt2);
118 double delta = (double) (cnt2.QuadPart - cnt1.QuadPart);
119 actual_time = delta / freq;
121 while (actual_time < target_time);
126 static double CalcCpuSpeed()
133 double seconds = SpinWait(0.1);
137 double clocks = clock2 - clock1;
139 return (clocks/seconds);
155 HINSTANCE DDHinst = 0;
156 LPDIRECT3D9 d3d9 = 0;
157 OSVERSIONINFO osVer = {
sizeof(OSVERSIONINFO) };
161 if (!GetVersionEx(&osVer))
165 if (osVer.dwPlatformId == VER_PLATFORM_WIN32_NT) {
166 if (osVer.dwMajorVersion <= 4)
170 DDHinst = LoadLibrary(
"D3D9.DLL");
175 FreeLibrary(DDHinst);
186 GetSystemInfo(&cpu_info);
188 if (cpu_info.wProcessorArchitecture != PROCESSOR_ARCHITECTURE_INTEL ||
189 cpu_info.dwProcessorType < PROCESSOR_INTEL_PENTIUM)
190 Print(
"INCOMPATIBLE CPU TYPE!\n");
196 cpu_class = cpu_info.wProcessorLevel;
208 cpu_speed = (int) (CalcCpuSpeed() / 1e6);
220 GlobalMemoryStatus(&mem_info);
221 total_ram = (int) (mem_info.dwTotalPhys/(1024*1024)) + 1;
233 GetVersionEx(&os_ver);
235 switch (os_ver.dwPlatformId) {
237 case VER_PLATFORM_WIN32s:
238 case VER_PLATFORM_WIN32_WINDOWS: {
240 sprintf_s(msg,
"Invalid Operating System Platform: %d\n", os_ver.dwPlatformId);
245 case VER_PLATFORM_WIN32_NT:
246 if (os_ver.dwMajorVersion == 4)
248 else if (os_ver.dwMajorVersion == 5 && os_ver.dwMinorVersion == 0)
250 else if (os_ver.dwMajorVersion == 5 && os_ver.dwMinorVersion == 1)
252 else if (os_ver.dwMajorVersion == 5 && os_ver.dwMinorVersion == 2)
254 else if (os_ver.dwMajorVersion == 6 && os_ver.dwMinorVersion == 0)
256 else if (os_ver.dwMajorVersion == 6 && os_ver.dwMinorVersion == 1)
258 else if (os_ver.dwMajorVersion >= 6)
264 Print(
"Invalid Operating System Platform (NT-series): %d.%d\n", os_ver.dwMajorVersion, os_ver.dwMinorVersion);
279 if (dx_version < 0) {
294 Print(
"+====================================================================+\n");
301 sprintf_s(txt,
"Windows 95 version %d.%d.%d %s",
302 os_ver.dwMajorVersion,
303 os_ver.dwMinorVersion,
304 LOWORD(os_ver.dwBuildNumber),
305 os_ver.szCSDVersion);
309 sprintf_s(txt,
"Windows 98 version %d.%d.%d %s",
310 os_ver.dwMajorVersion,
311 os_ver.dwMinorVersion,
312 LOWORD(os_ver.dwBuildNumber),
313 os_ver.szCSDVersion);
317 sprintf_s(txt,
"Windows NT %d.%d (Build %d) %s",
318 os_ver.dwMajorVersion,
319 os_ver.dwMinorVersion,
320 os_ver.dwBuildNumber,
321 os_ver.szCSDVersion);
325 sprintf_s(txt,
"Windows 2000 %d.%d (Build %d) %s",
326 os_ver.dwMajorVersion,
327 os_ver.dwMinorVersion,
328 os_ver.dwBuildNumber,
329 os_ver.szCSDVersion);
332 sprintf_s(txt,
"Windows XP %d.%d (Build %d) %s",
333 os_ver.dwMajorVersion,
334 os_ver.dwMinorVersion,
335 os_ver.dwBuildNumber,
336 os_ver.szCSDVersion);
339 sprintf_s(txt,
"Windows XP x64 %d.%d (Build %d) %s",
340 os_ver.dwMajorVersion,
341 os_ver.dwMinorVersion,
342 os_ver.dwBuildNumber,
343 os_ver.szCSDVersion);
346 sprintf_s(txt,
"Windows Vista %d.%d (Build %d) %s",
347 os_ver.dwMajorVersion,
348 os_ver.dwMinorVersion,
349 os_ver.dwBuildNumber,
350 os_ver.szCSDVersion);
353 sprintf_s(txt,
"Windows 7 %d.%d (Build %d) %s",
354 os_ver.dwMajorVersion,
355 os_ver.dwMinorVersion,
356 os_ver.dwBuildNumber,
357 os_ver.szCSDVersion);
360 sprintf_s(txt,
"Windows from the future %d.%d (Build %d) %s",
361 os_ver.dwMajorVersion,
362 os_ver.dwMinorVersion,
363 os_ver.dwBuildNumber,
364 os_ver.szCSDVersion);
368 sprintf_s(txt,
"Unknown Operating System Platform");
372 Print(
"| %-66s |\n", txt);
380 sprintf_s(txt,
"CPUs Detected: %d CPU Level: %d.%d.%d CPU Speed: %d",
381 cpu_info.dwNumberOfProcessors,
382 cpu_info.wProcessorLevel,
383 cpu_info.wProcessorRevision >> 8,
384 cpu_info.wProcessorRevision & 0xff,
387 Print(
"| %-66s |\n", txt);
390 GlobalMemoryStatus(&mem_info);
391 total_ram = (int) (mem_info.dwTotalPhys/(1024*1024)) + 1;
392 int swap_max = (int) (mem_info.dwTotalPageFile/(1024*1024));
393 int swap_avail = (int) (mem_info.dwAvailPageFile/(1024*1024));
395 sprintf_s(txt,
"%d MB RAM %d MB Max Swap %d MB Avail Swap",
396 total_ram, swap_max, swap_avail);
399 Print(
"| %-66s |\n", txt);
402 Print(
"| DirectX %d installed. |\n",
404 DescribeDXVersion(
"DDRAW");
405 DescribeDXVersion(
"D3DIM");
406 DescribeDXVersion(
"DINPUT");
407 DescribeDXVersion(
"DPLAY");
408 DescribeDXVersion(
"DSOUND");
409 DescribeDXVersion(
"DMUSIC");
410 DescribeDXVersion(
"DSHOW");
415 DescribeDrivers95(
"Display");
416 DescribeDrivers95(
"Media");
417 DescribeDrivers95(
"Monitor");
418 DescribeDrivers95(
"Multimedia");
421 DescribeDriversNT(
"");
424 Print(
"+====================================================================+\n");
430 static void DescribeCpuMake()
433 char sProcessor[256] =
"";
434 char sMMXInfo[256] =
"";
435 char sVendor[256] =
"";
438 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
439 "Hardware\\Description\\System\\CentralProcessor\\0",
442 &hkWin) == ERROR_SUCCESS) {
445 RegQueryValueEx(hkWin,
453 RegQueryValueEx(hkWin,
461 RegQueryValueEx(hkWin,
471 if (sProcessor[0])
Print(
"| %-66s |\n", sProcessor);
472 if (sMMXInfo[0])
Print(
"| %-66s |\n", sMMXInfo);
473 if (sVendor[0])
Print(
"| %-66s |\n", sVendor);
475 if (sProcessor[0] || sMMXInfo[0] || sVendor[0])
481 static void DescribeOwner95()
484 char sRegisteredOwner[256] =
"";
485 char sRegisteredOrganization[256] =
"";
488 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
489 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion",
492 &hkWin) == ERROR_SUCCESS) {
495 RegQueryValueEx(hkWin,
499 (LPBYTE) sRegisteredOwner,
503 RegQueryValueEx(hkWin,
504 "RegisteredOrganization",
507 (LPBYTE) sRegisteredOrganization,
513 Print(
"Could not access registered owner\n");
516 if (sRegisteredOwner[0]) {
518 sprintf_s(txt,
"Registered Owner: %s, %s", sRegisteredOwner, sRegisteredOrganization);
519 Print(
"| %-66s |\n", txt);
524 static void DescribeOwnerNT()
527 char sRegisteredOwner[256] =
"";
528 char sRegisteredOrganization[256] =
"";
531 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
532 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
535 &hkWin) == ERROR_SUCCESS) {
538 RegQueryValueEx(hkWin,
542 (LPBYTE) sRegisteredOwner,
546 RegQueryValueEx(hkWin,
547 "RegisteredOrganization",
550 (LPBYTE) sRegisteredOrganization,
556 Print(
"Could not access registered owner\n");
559 if (sRegisteredOwner[0]) {
561 sprintf_s(txt,
"Registered Owner: %s, %s", sRegisteredOwner, sRegisteredOrganization);
562 Print(
"| %-66s |\n", txt);
569 static void DescribeDrivers95(
const char* sType)
584 sprintf_s(sKey,
"System\\CurrentControlSet\\Services\\Class\\%s\\%04X", sType, nKey);
585 sprintf_s(sSub,
"System\\CurrentControlSet\\Services\\Class\\%s\\%04X\\DEFAULT", sType, nKey);
587 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
591 &hkWin) == ERROR_SUCCESS) {
594 RegQueryValueEx(hkWin,
602 sprintf_s(txt,
"* %s", sDriver);
603 Print(
"| %-66s |\n", txt);
609 ZeroMemory(sDriver,
sizeof(sDriver));
612 DWORD
err = RegQueryValueEx(hkWin,
"Driver", NULL, NULL, (LPBYTE) sDriver, &dwSize);
614 if (err != ERROR_SUCCESS) {
616 err = RegQueryValueEx(hkWin,
"DeviceDriver", NULL, NULL, (LPBYTE) sDriver, &dwSize);
619 if (err != ERROR_SUCCESS) {
621 err = RegQueryValueEx(hkWin,
"drv", NULL, NULL, (LPBYTE) sDriver, &dwSize);
624 if (err != ERROR_SUCCESS) {
625 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
629 &hkSub) == ERROR_SUCCESS) {
632 err = RegQueryValueEx(hkSub,
"drv", NULL, NULL, (LPBYTE) sDriver, &dwSize);
639 if (err == ERROR_SUCCESS) {
640 DescribeDriverVersion(sDriver);
654 static void DescribeDriversNT(
const char* sType)
659 char sVideo[256] =
"";
660 char sDriver[256] =
"";
664 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
665 "HARDWARE\\DEVICEMAP\\VIDEO",
668 &hkWin) == ERROR_SUCCESS) {
671 RegQueryValueEx(hkWin,
682 if (dwSize && sVideo[0]) {
683 const char* sLeader =
"\\REGISTRY\\Machine\\";
684 int nLeader = strlen(sLeader);
686 if (_strnicmp(sVideo, sLeader, nLeader) == 0) {
687 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
691 &hkWin) == ERROR_SUCCESS) {
694 RegQueryValueEx(hkWin,
695 "Device Description",
707 Print(
"| %-66s |\n", sDriver);
714 static char sTranslation[16];
716 static void GetTranslation(
const LPBYTE pBlock)
721 if (VerQueryValue(pBlock,
"\\VarFileInfo\\Translation",
722 (LPVOID*) &sData, &lenData)) {
724 if (lenData && sData) {
725 sprintf_s(sTranslation,
"%02X%02X%02X%02X", sData[1], sData[0], sData[3], sData[2]);
733 char sFullSection[256];
735 sprintf_s(sFullSection,
"\\StringFileInfo\\%s\\%s", sTranslation, sSection);
741 if (VerQueryValue(pBlock, sFullSection, (LPVOID*) &sData, &lenData)) {
742 if (lenData && sData) {
743 sprintf_s(txt,
"%-16s %s", sSection, sData);
744 Print(
"| %-60s |\n", txt);
749 static void DescribeDriverVersion(
const char* file)
754 strcpy_s(szFile, file);
756 int nBytes = GetFileVersionInfoSize(szFile, &dwHandle);
760 GetSystemDirectory(szWinDir, 256);
761 sprintf_s(szFile,
"%s\\%s", szWinDir, file);
763 nBytes = GetFileVersionInfoSize(szFile, &dwHandle);
769 LPBYTE pBlock =
new(__FILE__,__LINE__) BYTE[nBytes];
771 if (pBlock && GetFileVersionInfo(szFile, dwHandle, nBytes, (LPVOID) pBlock)) {
772 GetTranslation(pBlock);
790 static void DescribeDXVersion(
const char* component)
796 GetSystemDirectory(szWinDir, 512);
798 sprintf_s(szFile,
"%s\\%s.dll", szWinDir, component);
800 int nBytes = GetFileVersionInfoSize(szFile, &dwHandle);
806 LPBYTE pBlock =
new(__FILE__,__LINE__) BYTE[nBytes];
808 if (pBlock && GetFileVersionInfo(szFile, dwHandle, nBytes, (LPVOID) pBlock)) {
809 GetTranslation(pBlock);
812 char sFullSection[256];
817 sprintf_s(sFullSection,
"\\StringFileInfo\\%s\\FileVersion", sTranslation);
819 if (VerQueryValue(pBlock, sFullSection, (LPVOID*) &sData, &lenData)) {
820 if (lenData && sData) {
821 sprintf_s(txt,
"%-8s%s", component, sData);
822 Print(
"| %-64s |\n", txt);