ReactOS 0.4.16-dev-1475-g410db43
systeminfo.c File Reference
#include <wchar.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <windows.h>
#include <time.h>
#include <locale.h>
#include <lm.h>
#include <shlwapi.h>
#include <iphlpapi.h>
#include <winsock2.h>
#include <udmihelp.h>
#include <conutils.h>
#include "resource.h"
Include dependency graph for systeminfo.c:

Go to the source code of this file.

Macros

#define BUFFER_SIZE   1024
 

Functions

static UINT RegGetSZ (HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPWSTR lpBuf, DWORD cchBuf)
 
static BOOL RegGetDWORD (HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPDWORD lpData)
 
static VOID FormatBytes (LPWSTR lpBuf, UINT cBytes)
 
static VOID FormatDateTime (time_t Time, LPWSTR lpBuf)
 
ULONGLONG GetSecondsQPC (VOID)
 
ULONGLONG GetSeconds (VOID)
 
static VOID Usage (VOID)
 
static VOID PrintRow (UINT nTitleID, BOOL bIndent, LPWSTR lpFormat,...)
 
VOID AllSysInfo (VOID)
 
int wmain (int argc, wchar_t *argv[])
 

Macro Definition Documentation

◆ BUFFER_SIZE

#define BUFFER_SIZE   1024

Definition at line 26 of file systeminfo.c.

Function Documentation

◆ AllSysInfo()

VOID AllSysInfo ( VOID  )

Definition at line 257 of file systeminfo.c.

258{
259 DWORD dwCharCount, dwTimestamp, dwResult;
261 SYSTEM_INFO SysInfo;
262 WCHAR Buf[BUFFER_SIZE], Tmp[BUFFER_SIZE], szSystemDir[MAX_PATH];
263 LPCWSTR lpcszSysType;
265 NETSETUP_JOIN_STATUS NetJoinStatus;
266 MEMORYSTATUS MemoryStatus;
267 UINT cSeconds, i, j;
268 TIME_ZONE_INFORMATION TimeZoneInfo;
269 HKEY hKey;
270 PIP_ADAPTER_ADDRESSES pAdapters;
271 ULONG cbAdapters;
272 PVOID SMBiosBuf;
273 PCHAR DmiStrings[ID_STRINGS_MAX] = { 0 };
274
275 if (!GetSystemDirectoryW(szSystemDir, _countof(szSystemDir)))
276 {
277 ConPrintf(StdErr, L"Error! GetSystemDirectory failed.\n");
278 return;
279 }
280
281 GetSystemInfo(&SysInfo);
282
283 /* Getting computer name */
284 dwCharCount = _countof(Buf);
285 if (!GetComputerNameW(Buf, &dwCharCount))
286 ConPrintf(StdErr, L"Error! GetComputerName failed.\n");
287 else
288 PrintRow(IDS_HOST_NAME, FALSE, L"%s", Buf);
289
290 /* Open CurrentVersion key */
292 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
293 0,
295 &hKey) != ERROR_SUCCESS)
296 {
297 ConPrintf(StdErr, L"Error! RegOpenKeyEx failed.\n");
298 return;
299 }
300
301 /* Getting OS Name */
302 RegGetSZ(hKey, NULL, L"ProductName", Buf, _countof(Buf));
303 PrintRow(IDS_OS_NAME, FALSE, L"%s", Buf);
304
305 /* Getting OS Version */
309
311 Tmp[0] = L'\0';
313 FALSE,
314 L"%lu.%lu.%lu %s %s %lu",
319 Tmp,
321
322 /* Getting OS Manufacturer */
323
324 /* Getting OS Configuration */
325
326 /* Getting OS Build Type */
327 RegGetSZ(hKey, NULL, L"CurrentType", Buf, _countof(Buf));
328 PrintRow(IDS_OS_BUILD_TYPE, FALSE, L"%s", Buf);
329
330 /* Getting Registered Owner */
331 RegGetSZ(hKey, NULL, L"RegisteredOwner", Buf, _countof(Buf));
332 PrintRow(IDS_REG_OWNER, FALSE, L"%s", Buf);
333
334 /* Getting Registered Organization */
335 RegGetSZ(hKey, NULL, L"RegisteredOrganization", Buf, _countof(Buf));
336 PrintRow(IDS_REG_ORG, FALSE, L"%s", Buf);
337
338 /* Getting Product ID */
339 RegGetSZ(hKey, NULL, L"ProductId", Buf, _countof(Buf));
340 PrintRow(IDS_PRODUCT_ID, FALSE, L"%s", Buf);
341
342 /* Getting Install Date */
343 RegGetDWORD(hKey, NULL, L"InstallDate", &dwTimestamp);
344 FormatDateTime((time_t)dwTimestamp, Buf);
345 PrintRow(IDS_INST_DATE, FALSE, L"%s", Buf);
346
347 /* Close Current Version key now */
349
350 /* Getting System Up Time */
351 cSeconds = GetSeconds();
353 Tmp[0] = L'\0';
354 swprintf(Buf, Tmp, cSeconds / (60*60*24), (cSeconds / (60*60)) % 24, (cSeconds / 60) % 60, cSeconds % 60);
355 PrintRow(IDS_UP_TIME, FALSE, L"%s", Buf);
356
357 /* Prepare SMBIOS data */
358 SMBiosBuf = LoadSMBiosData(DmiStrings);
359
360 /* Getting System Manufacturer;
361 * HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation\Manufacturer
362 * for Win >= 6.0 */
363 swprintf(Tmp, L"%s\\oeminfo.ini", szSystemDir);
365 L"Manufacturer",
366 L"",
367 Buf,
368 _countof(Buf),
369 Tmp);
370 if (wcslen(Buf) == 0 && SMBiosBuf)
371 {
372 GetSMBiosStringW(DmiStrings[SYS_VENDOR], Buf, _countof(Buf), FALSE);
373 }
375
376 /* Getting System Model;
377 * HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation\Model
378 * for Win >= 6.0 */
380 L"Model",
381 L"",
382 Buf,
383 _countof(Buf),
384 Tmp);
385 if (wcslen(Buf) == 0 && SMBiosBuf)
386 {
387 GetSMBiosStringW(DmiStrings[SYS_PRODUCT], Buf, _countof(Buf), FALSE);
388 }
389 PrintRow(IDS_SYS_MODEL, FALSE, L"%s", Buf);
390
391 /* Getting System type */
392 switch (SysInfo.wProcessorArchitecture)
393 {
395 lpcszSysType = L"X86-based PC";
396 break;
398 lpcszSysType = L"IA64-based PC";
399 break;
401 lpcszSysType = L"AMD64-based PC";
402 break;
403 default:
404 lpcszSysType = L"Unknown";
405 break;
406 }
407 PrintRow(IDS_SYS_TYPE, FALSE, L"%s", lpcszSysType);
408
409 /* Getting Processor(s) */
411 Tmp[0] = L'\0';
412 swprintf(Buf, Tmp, (UINT)SysInfo.dwNumberOfProcessors);
413 PrintRow(IDS_PROCESSORS, FALSE, L"%s", Buf);
414 for (i = 0; i < (UINT)SysInfo.dwNumberOfProcessors; i++)
415 {
416 swprintf(Tmp, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u", i);
417 j = swprintf(Buf, L"[%02u]: ", i + 1);
418
419 j += RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"Identifier", Buf + j, _countof(Buf) - j);
420 if (j + 1 < _countof(Buf))
421 Buf[j++] = L' ';
422 RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"VendorIdentifier", Buf + j, _countof(Buf) - j);
423
424 PrintRow(0, FALSE, L"%s", Buf);
425 }
426
427 /* Getting BIOS Version */
428 if (SMBiosBuf)
429 {
430 j = GetSMBiosStringW(DmiStrings[BIOS_VENDOR], Buf, _countof(Buf), TRUE);
431 if (j + 1 < _countof(Buf))
432 {
433 Buf[j++] = L' ';
434 Buf[j] = L'\0';
435 }
436 GetSMBiosStringW(DmiStrings[BIOS_VERSION], Buf + j, _countof(Buf) - j, TRUE);
437 }
438 else
439 {
441 L"HARDWARE\\DESCRIPTION\\System",
442 L"SystemBiosVersion",
443 Buf,
444 _countof(Buf));
445 }
446 PrintRow(IDS_BIOS_VERSION, FALSE, L"%s", Buf);
447
448 /* Getting BIOS date */
449 if (SMBiosBuf)
450 {
451 GetSMBiosStringW(DmiStrings[BIOS_DATE], Buf, _countof(Buf), TRUE);
452 }
453 else
454 {
456 L"HARDWARE\\DESCRIPTION\\System",
457 L"SystemBiosDate",
458 Buf,
459 _countof(Buf));
460 }
461 PrintRow(IDS_BIOS_DATE, FALSE, L"%s", Buf);
462
463 /* Clean SMBIOS data */
464 FreeSMBiosData(SMBiosBuf);
465
466 /* Getting ReactOS Directory */
467 if (!GetWindowsDirectoryW(Buf, _countof(Buf)))
468 ConPrintf(StdErr, L"Error! GetWindowsDirectory failed.");
469 else
470 PrintRow(IDS_ROS_DIR, FALSE, L"%s", Buf);
471
472 /* Getting System Directory */
473 PrintRow(IDS_SYS_DIR, 0, L"%s", szSystemDir);
474
475 /* Getting Boot Device */
477 L"SYSTEM\\Setup",
478 L"SystemPartition",
479 Buf,
480 _countof(Buf));
481 PrintRow(IDS_BOOT_DEV, FALSE, L"%s", Buf);
482
483 /* Getting System Locale */
485 {
487 L"MIME\\Database\\Rfc1766",
488 Tmp,
489 Buf,
490 _countof(Buf)))
491 {
492 /* Get rid of @filename,resource */
493 lpBuffer = wcschr(Buf, L';');
494 if (lpBuffer)
496
497 PrintRow(IDS_SYS_LOCALE, FALSE, L"%s", Buf);
498 }
499 }
500
501 /* Getting Input Locale */
503 L"Keyboard Layout\\Preload",
504 L"1",
505 Tmp,
506 _countof(Tmp)) && wcslen(Tmp) > 4)
507 {
509 L"MIME\\Database\\Rfc1766",
510 Tmp + 4,
511 Buf,
512 _countof(Buf)))
513 {
514 /* Get rid of @filename,resource */
515 lpBuffer = wcschr(Buf, L';');
516 if (lpBuffer)
518
519 PrintRow(IDS_INPUT_LOCALE, FALSE, L"%s", Buf);
520 }
521 }
522
523 /* Getting Time Zone */
524 GetTimeZoneInformation(&TimeZoneInfo);
525
526 /* Open Time Zones key */
528 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
529 0,
531 &hKey) == ERROR_SUCCESS)
532 {
533 /* Find current timezone */
534 UINT i;
535 dwCharCount = _countof(Tmp);
536 for (i = 0; RegEnumKeyExW(hKey, i, Tmp, &dwCharCount, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++i, dwCharCount = 255)
537 {
538 RegGetSZ(hKey, Tmp, L"Std", Buf, _countof(Buf));
539
540 if (!wcscmp(Buf, TimeZoneInfo.StandardName))
541 {
542 RegGetSZ(hKey, Tmp, L"Display", Buf, _countof(Buf));
543
544 PrintRow(IDS_TIME_ZONE, FALSE, L"%s", Buf);
545
546 break;
547 }
548 }
550 }
551
552 /* Getting Total Physical Memory */
553 GlobalMemoryStatus(&MemoryStatus);
554 FormatBytes(Buf, MemoryStatus.dwTotalPhys);
556
557 /* Getting Available Physical Memory */
558 FormatBytes(Buf, MemoryStatus.dwAvailPhys);
560
561 /* Getting Virtual Memory: Max Size */
562 FormatBytes(Buf, MemoryStatus.dwTotalVirtual);
563 PrintRow(IDS_VIRT_MEM_MAX, FALSE, L"%s", Buf);
564
565 /* Getting Virtual Memory: Available */
566 FormatBytes(Buf, MemoryStatus.dwAvailVirtual);
568
569 /* Getting Virtual Memory: In Use */
570 FormatBytes(Buf, MemoryStatus.dwTotalVirtual-MemoryStatus.dwAvailVirtual);
572
573 /* Getting Page File Location(s) */
575 L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management",
576 L"PagingFiles",
577 Buf,
578 _countof(Buf)))
579 {
580 UINT i;
581 for (i = 0; Buf[i]; i++)
582 {
583 if (Buf[i] == L' ')
584 {
585 Buf[i] = L'\0';
586 break;
587 }
588 }
589
590 PrintRow(IDS_PAGEFILE_LOC, FALSE, L"%s", Buf);
591 }
592
593 /* Getting Domain */
594 if (NetGetJoinInformation (NULL, &lpBuffer, &NetJoinStatus) == NERR_Success)
595 {
596 if (NetJoinStatus == NetSetupWorkgroupName || NetJoinStatus == NetSetupDomainName)
598
600 }
601
602 /* Getting Logon Server */
603
604 /* Getting NetWork Card(s) */
605 cbAdapters = 4096;
606 pAdapters = malloc(cbAdapters);
607 while ((dwResult = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST, NULL, pAdapters, &cbAdapters)) == ERROR_BUFFER_OVERFLOW)
608 {
609 cbAdapters += 4096;
610 pAdapters = (PIP_ADAPTER_ADDRESSES)realloc(pAdapters, cbAdapters);
611 }
612
613 if (dwResult == ERROR_SUCCESS)
614 {
615 PIP_ADAPTER_ADDRESSES pCurrentAdapter = pAdapters;
616 UINT cAdapters = 0;
617
618 /* Count adapters */
619 for (i = 0; pCurrentAdapter; ++i)
620 {
621 if (pCurrentAdapter->IfType != IF_TYPE_SOFTWARE_LOOPBACK && pCurrentAdapter->IfType != IF_TYPE_TUNNEL)
622 ++cAdapters;
623 pCurrentAdapter = pCurrentAdapter->Next;
624 }
625
626 /* Print adapters count */
628 Tmp[0] = L'\0';
629 swprintf(Buf, Tmp, cAdapters);
630 PrintRow(IDS_NETWORK_CARDS, FALSE, L"%s", Buf);
631
632 /* Show information about each adapter */
633 pCurrentAdapter = pAdapters;
634 for (i = 0; pCurrentAdapter; ++i)
635 {
636 if (pCurrentAdapter->IfType != IF_TYPE_SOFTWARE_LOOPBACK && pCurrentAdapter->IfType != IF_TYPE_TUNNEL)
637 {
638 PIP_ADAPTER_UNICAST_ADDRESS pAddress;
639
640 PrintRow(0, FALSE, L"[%02u]: %s", i + 1, pCurrentAdapter->Description);
641 PrintRow(IDS_CONNECTION_NAME, TRUE, L"%s", pCurrentAdapter->FriendlyName);
642 if (!(pCurrentAdapter->Flags & IP_ADAPTER_DHCP_ENABLED))
643 {
645 Buf[0] = L'\0';
647 }
648 if (pCurrentAdapter->OperStatus == IfOperStatusDown)
649 {
651 Buf[0] = L'\0';
652 PrintRow(IDS_STATUS, TRUE, Buf);
653 }
654 else
655 {
657 Buf[0] = L'\0';
658 PrintRow(0, TRUE, Buf);
659 pAddress = pCurrentAdapter->FirstUnicastAddress;
660 for (j = 0; pAddress; ++j)
661 {
662 dwCharCount = _countof(Buf);
663 WSAAddressToStringW(pAddress->Address.lpSockaddr, pAddress->Address.iSockaddrLength, NULL, Buf, &dwCharCount);
664 PrintRow(0, TRUE, L"[%02u]: %s", j + 1, Buf);
665 pAddress = pAddress->Next;
666 }
667 }
668 }
669 pCurrentAdapter = pCurrentAdapter->Next;
670 }
671 }
672 free(pAdapters);
673}
#define IDS_NO
Definition: resource.h:17
#define IDS_STATUS
Definition: resource.h:22
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
#define StdErr
Definition: fc.c:15
#define IDS_OS_VERSION
Definition: resource.h:155
OSVERSIONINFOW VersionInfo
Definition: wkssvc.c:40
#define RegCloseKey(hKey)
Definition: registry.h:49
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
#define wcschr
Definition: compat.h:17
#define MAX_PATH
Definition: compat.h:34
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2313
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
Definition: version.c:37
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
Definition: timezone.c:262
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1675
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
HRESULT WINAPI SHLoadIndirectString(const WCHAR *src, WCHAR *dst, UINT dst_len, void **reserved)
Definition: string.c:1455
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
#define swprintf
Definition: precomp.h:40
@ BIOS_VERSION
Definition: dmilib.h:14
@ SYS_PRODUCT
Definition: dmilib.h:17
@ ID_STRINGS_MAX
Definition: dmilib.h:28
@ BIOS_DATE
Definition: dmilib.h:15
@ SYS_VENDOR
Definition: dmilib.h:16
@ BIOS_VENDOR
Definition: dmilib.h:13
#define L(x)
Definition: resources.c:13
__kernel_time_t time_t
Definition: linux.h:252
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
VOID NTAPI GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer)
Definition: heapmem.c:1365
@ IfOperStatusDown
Definition: ifdef.h:186
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static PIP_ADAPTER_ADDRESSES
Definition: iphlpapi.c:76
#define IF_TYPE_TUNNEL
Definition: ipifcons.h:151
#define IF_TYPE_SOFTWARE_LOOPBACK
Definition: ipifcons.h:44
#define NERR_Success
Definition: lmerr.h:5
@ NetSetupDomainName
Definition: lmjoin.h:13
@ NetSetupWorkgroupName
Definition: lmjoin.h:12
enum _NETSETUP_JOIN_STATUS NETSETUP_JOIN_STATUS
#define IDS_PAGEFILE_LOC
Definition: resource.h:33
#define IDS_SYS_DIR
Definition: resource.h:24
#define IDS_UP_TIME
Definition: resource.h:14
#define IDS_VIRT_MEM_INUSE
Definition: resource.h:32
#define IDS_SYS_MANUFACTURER
Definition: resource.h:16
#define IDS_CONNECTION_NAME
Definition: resource.h:38
#define IDS_SYS_LOCALE
Definition: resource.h:26
#define IDS_SYS_TYPE
Definition: resource.h:18
#define IDS_PROCESSORS_FORMAT
Definition: resource.h:20
#define IDS_UP_TIME_FORMAT
Definition: resource.h:15
#define IDS_NETWORK_CARDS
Definition: resource.h:36
#define IDS_TOTAL_PHYS_MEM
Definition: resource.h:28
#define IDS_AVAIL_PHISICAL_MEM
Definition: resource.h:29
#define IDS_TIME_ZONE
Definition: resource.h:34
#define IDS_BIOS_VERSION
Definition: resource.h:22
#define IDS_SYS_MODEL
Definition: resource.h:17
#define IDS_MEDIA_DISCONNECTED
Definition: resource.h:40
#define IDS_OS_BUILD_TYPE
Definition: resource.h:9
#define IDS_HOST_NAME
Definition: resource.h:5
#define IDS_REG_OWNER
Definition: resource.h:10
#define IDS_INPUT_LOCALE
Definition: resource.h:27
#define IDS_VIRT_MEM_MAX
Definition: resource.h:30
#define IDS_OS_NAME
Definition: resource.h:6
#define IDS_ROS_DIR
Definition: resource.h:23
#define IDS_IP_ADDRESSES
Definition: resource.h:43
#define IDS_PRODUCT_ID
Definition: resource.h:12
#define IDS_REG_ORG
Definition: resource.h:11
#define IDS_BOOT_DEV
Definition: resource.h:25
#define IDS_DOMAIN
Definition: resource.h:35
#define IDS_VIRT_MEM_AVAIL
Definition: resource.h:31
#define IDS_BUILD
Definition: resource.h:8
#define IDS_DHCP_ENABLED
Definition: resource.h:41
#define IDS_INST_DATE
Definition: resource.h:13
#define IDS_PROCESSORS
Definition: resource.h:19
#define IDS_BIOS_DATE
Definition: resource.h:21
#define IDS_NETWORK_CARDS_FORMAT
Definition: resource.h:37
static VOID FormatBytes(LPWSTR lpBuf, UINT cBytes)
Definition: systeminfo.c:127
static BOOL RegGetDWORD(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPDWORD lpData)
Definition: systeminfo.c:86
static VOID FormatDateTime(time_t Time, LPWSTR lpBuf)
Definition: systeminfo.c:151
static UINT RegGetSZ(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPWSTR lpBuf, DWORD cchBuf)
Definition: systeminfo.c:31
static VOID PrintRow(UINT nTitleID, BOOL bIndent, LPWSTR lpFormat,...)
Definition: systeminfo.c:222
#define BUFFER_SIZE
Definition: systeminfo.c:26
ULONGLONG GetSeconds(VOID)
Definition: systeminfo.c:188
unsigned int UINT
Definition: ndis.h:50
#define PROCESSOR_ARCHITECTURE_IA64
Definition: ketypes.h:111
#define PROCESSOR_ARCHITECTURE_AMD64
Definition: ketypes.h:114
#define PROCESSOR_ARCHITECTURE_INTEL
Definition: ketypes.h:105
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define LOCALE_SYSTEM_DEFAULT
INT WSAAPI WSAAddressToStringW(IN LPSOCKADDR lpsaAddress, IN DWORD dwAddressLength, IN LPWSAPROTOCOL_INFOW lpProtocolInfo, OUT LPWSTR lpszAddressString, IN OUT LPDWORD lpdwAddressStringLength)
Definition: rnr.c:128
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define _countof(array)
Definition: sndvol32.h:70
SIZE_T dwTotalPhys
Definition: winbase.h:1259
SIZE_T dwAvailVirtual
Definition: winbase.h:1264
SIZE_T dwAvailPhys
Definition: winbase.h:1260
SIZE_T dwTotalVirtual
Definition: winbase.h:1263
ULONG dwMinorVersion
Definition: rtltypes.h:248
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:246
ULONG dwMajorVersion
Definition: rtltypes.h:247
ULONG dwBuildNumber
Definition: rtltypes.h:249
WCHAR szCSDVersion[128]
Definition: rtltypes.h:251
DWORD dwNumberOfProcessors
Definition: winbase.h:1218
WORD wProcessorArchitecture
Definition: winbase.h:1210
WCHAR StandardName[32]
Definition: winbase.h:1248
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
SIZE_T GetSMBiosStringW(_In_ PCSTR DmiString, _Out_ PWSTR pBuf, _In_ DWORD cchBuf, _In_ BOOL bTrim)
Definition: udmihelp.c:145
PVOID LoadSMBiosData(_Inout_updates_(ID_STRINGS_MAX) PCHAR *Strings)
Definition: udmihelp.c:30
VOID FreeSMBiosData(_In_ PVOID Buffer)
Definition: udmihelp.c:177
#define ZeroMemory
Definition: winbase.h:1753
#define GetModuleHandle
Definition: winbase.h:3868
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
#define LOCALE_ILANGUAGE
Definition: winnls.h:30
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define AF_UNSPEC
Definition: winsock.h:344
NET_API_STATUS WINAPI NetGetJoinInformation(_In_ LPCWSTR lpServer, _Out_ LPWSTR *lpNameBuffer, _Out_ PNETSETUP_JOIN_STATUS BufferType)
Definition: wksta_new.c:317
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by wmain().

◆ FormatBytes()

static VOID FormatBytes ( LPWSTR  lpBuf,
UINT  cBytes 
)
static

Definition at line 127 of file systeminfo.c.

128{
129 WCHAR szMB[32];
131 UINT i;
132
133 _itow(cBytes / (1024*1024), szMB, 10);
134
135 fmt.NumDigits = 0;
136 fmt.LeadingZero = 0;
137 fmt.Grouping = 3;
138 fmt.lpDecimalSep = L"";
139 fmt.lpThousandSep = L" ";
140 fmt.NegativeOrder = 0;
141
142 i = GetNumberFormatW(LOCALE_SYSTEM_DEFAULT, 0, szMB, &fmt, lpBuf, BUFFER_SIZE - 3);
143 if (i)
144 --i; /* don't count NULL character */
145 wcscpy(lpBuf + i, L" MB");
146}
wcscpy
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1208
_CRTIMP wchar_t *__cdecl _itow(_In_ int _Value, _Pre_notnull_ _Post_z_ wchar_t *_Dest, _In_ int _Radix)
Definition: dsound.c:943

Referenced by AllSysInfo().

◆ FormatDateTime()

static VOID FormatDateTime ( time_t  Time,
LPWSTR  lpBuf 
)
static

Definition at line 151 of file systeminfo.c.

152{
153 UINT i;
154 SYSTEMTIME SysTime;
155 const struct tm *lpTm;
156
157 lpTm = localtime(&Time);
158 SysTime.wYear = (WORD)(1900 + lpTm->tm_year);
159 SysTime.wMonth = (WORD)(1 + lpTm->tm_mon);
160 SysTime.wDayOfWeek = (WORD)lpTm->tm_wday;
161 SysTime.wDay = (WORD)lpTm->tm_mday;
162 SysTime.wHour = (WORD)lpTm->tm_hour;
163 SysTime.wMinute = (WORD)lpTm->tm_min;
164 SysTime.wSecond = (WORD)lpTm->tm_sec;
165 SysTime.wMilliseconds = 0;
166
167 /* Copy date first */
168 i = GetDateFormatW(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf, BUFFER_SIZE - 2);
169 if (i)
170 --i; /* don't count NULL character */
171
172 /* Copy time now */
173 i += swprintf(lpBuf + i, L", ");
174
175 GetTimeFormatW(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf + i, BUFFER_SIZE - i);
176}
unsigned short WORD
Definition: ntddk_ex.h:93
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1089
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:989
static PLARGE_INTEGER Time
Definition: time.c:105
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:416
WORD wYear
Definition: winbase.h:946
WORD wMilliseconds
Definition: winbase.h:953
WORD wMonth
Definition: winbase.h:947
WORD wHour
Definition: winbase.h:950
WORD wSecond
Definition: winbase.h:952
WORD wMinute
Definition: winbase.h:951
WORD wDay
Definition: winbase.h:949
WORD wDayOfWeek
Definition: winbase.h:948
Definition: time.h:68
int tm_mon
Definition: time.h:73
int tm_year
Definition: time.h:74
int tm_hour
Definition: time.h:71
int tm_sec
Definition: time.h:69
int tm_mday
Definition: time.h:72
int tm_min
Definition: time.h:70
int tm_wday
Definition: time.h:75

Referenced by AllSysInfo().

◆ GetSeconds()

ULONGLONG GetSeconds ( VOID  )

Definition at line 188 of file systeminfo.c.

189{
191 ULONGLONG Ticks64;
192 HMODULE hModule = GetModuleHandleW(L"kernel32.dll");
193
194 pGetTickCount64 = (PVOID)GetProcAddress(hModule, "GetTickCount64");
195 if (pGetTickCount64)
196 return pGetTickCount64() / 1000;
197
198 hModule = LoadLibraryW(L"kernel32_vista.dll");
199 if (!hModule)
200 return GetSecondsQPC();
201
202 pGetTickCount64 = (PVOID)GetProcAddress(hModule, "GetTickCount64");
203 if (pGetTickCount64)
204 Ticks64 = pGetTickCount64() / 1000;
205 else
206 Ticks64 = GetSecondsQPC();
207
209 return Ticks64;
210}
#define VOID
Definition: acefi.h:82
static PFGETTICKCOUNT64 pGetTickCount64
Definition: general.c:36
HMODULE hModule
Definition: animate.c:44
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
ULONGLONG GetSecondsQPC(VOID)
Definition: systeminfo.c:178
void * PVOID
Definition: typedefs.h:50
uint64_t ULONGLONG
Definition: typedefs.h:67
#define WINAPI
Definition: msvc.h:6

Referenced by AllSysInfo().

◆ GetSecondsQPC()

ULONGLONG GetSecondsQPC ( VOID  )

Definition at line 178 of file systeminfo.c.

179{
181
184
186}
BOOL WINAPI QueryPerformanceFrequency(OUT PLARGE_INTEGER lpFrequency)
Definition: perfcnt.c:45
BOOL WINAPI QueryPerformanceCounter(OUT PLARGE_INTEGER lpPerformanceCount)
Definition: perfcnt.c:23
static LARGE_INTEGER Frequency
Definition: clock.c:41
static LARGE_INTEGER Counter
Definition: clock.c:43
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by GetSeconds().

◆ PrintRow()

static VOID PrintRow ( UINT  nTitleID,
BOOL  bIndent,
LPWSTR  lpFormat,
  ... 
)
static

Definition at line 222 of file systeminfo.c.

223{
225 UINT c;
226 WCHAR Buf[BUFFER_SIZE];
227
228 if (nTitleID)
229 {
230 c = LoadStringW(GetModuleHandle(NULL), nTitleID, Buf, _countof(Buf) - 2);
231 if (!c)
232 return;
233
234 wcscpy(Buf + c, L": ");
235 }
236 else
237 {
238 Buf[0] = L'\0';
239 }
240
241 if (!bIndent)
242 ConPrintf(StdOut, L"%-32s", Buf);
243 else if (Buf[0])
244 ConPrintf(StdOut, L"%38s%-16s", L"", Buf);
245 else
246 ConPrintf(StdOut, L"%38s", L"");
247
250 va_end(Args);
251
252 ConPuts(StdOut, L"\n");
253}
char ** Args
Definition: acdebug.h:353
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define StdOut
Definition: fc.c:14
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
INT ConPrintfV(IN PCON_STREAM Stream, IN PCWSTR szStr, IN va_list args)
Definition: outstream.c:466
LPCWSTR lpFormat
Definition: trayclock.cpp:32

Referenced by AllSysInfo().

◆ RegGetDWORD()

static BOOL RegGetDWORD ( HKEY  hKey,
LPCWSTR  lpSubKey,
LPCWSTR  lpValueName,
LPDWORD  lpData 
)
static

Definition at line 86 of file systeminfo.c.

87{
88 DWORD dwBytes = sizeof(*lpData), dwType;
89 BOOL bRet = TRUE;
90
91 /* If SubKey is specified open it */
92 if (lpSubKey && RegOpenKeyExW(hKey,
93 lpSubKey,
94 0,
97 {
98 ConPrintf(StdErr, L"Warning! Cannot open %s. Last error: %lu.\n",
99 lpSubKey, GetLastError());
100 return FALSE;
101 }
102
103 /* Query registry value and check its type */
105 lpValueName,
106 NULL,
107 &dwType,
108 (LPBYTE)lpData,
109 &dwBytes) != ERROR_SUCCESS || dwType != REG_DWORD)
110 {
111 ConPrintf(StdErr, L"Warning! Cannot query %s. Last err: %lu, type: %lu\n",
112 lpValueName, GetLastError(), dwType);
113 *lpData = 0;
114 bRet = FALSE;
115 }
116
117 /* Close key if we opened it */
118 if (lpSubKey)
120
121 return bRet;
122}
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
unsigned int BOOL
Definition: ntddk_ex.h:94
#define REG_DWORD
Definition: sdbapi.c:596
unsigned char * LPBYTE
Definition: typedefs.h:53
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by AllSysInfo().

◆ RegGetSZ()

static UINT RegGetSZ ( HKEY  hKey,
LPCWSTR  lpSubKey,
LPCWSTR  lpValueName,
LPWSTR  lpBuf,
DWORD  cchBuf 
)
static

Definition at line 31 of file systeminfo.c.

32{
33 DWORD dwBytes = cchBuf * sizeof(WCHAR), dwType = 0;
35
36 /* If SubKey is specified open it */
37 if (lpSubKey && RegOpenKeyExW(hKey,
38 lpSubKey,
39 0,
42 {
43 ConPrintf(StdErr, L"Warning! Cannot open %s. Last error: %lu.\n",
44 lpSubKey, GetLastError());
45 return 0;
46 }
47
48 /* Query registry value and check its type */
50 lpValueName,
51 NULL,
52 &dwType,
53 (LPBYTE)lpBuf,
54 &dwBytes) != ERROR_SUCCESS ||
55 (dwType != REG_SZ && dwType != REG_MULTI_SZ))
56 {
57 ConPrintf(StdErr, L"Warning! Cannot query %s. Last error: %lu, type: %lu.\n",
58 lpValueName, GetLastError(), dwType);
59 dwBytes = 0;
60 }
61 else if (dwBytes == 0)
62 {
63 wcscpy(lpBuf, L"N/A");
64 dwBytes = sizeof(L"N/A")-sizeof(WCHAR);
65 }
66
67 /* Close key if we opened it */
68 if (lpSubKey)
70
71 cChars = dwBytes/sizeof(WCHAR);
72
73 /* NULL-terminate string */
74 lpBuf[min(cchBuf-1, cChars)] = L'\0';
75
76 /* Don't count NULL characters */
77 while (cChars && !lpBuf[cChars-1])
78 --cChars;
79
80 return cChars;
81}
#define REG_SZ
Definition: layer.c:22
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG int TEXTRANGE_PROPERTIES int const WCHAR int cChars
Definition: usp10.c:64
#define min(a, b)
Definition: monoChain.cc:55
#define REG_MULTI_SZ
Definition: nt_native.h:1501

Referenced by AllSysInfo().

◆ Usage()

static VOID Usage ( VOID  )
static

Definition at line 215 of file systeminfo.c.

216{
218}
#define IDS_USAGE
Definition: resource.h:3
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33

◆ wmain()

int wmain ( int  argc,
wchar_t argv[] 
)

Definition at line 676 of file systeminfo.c.

677{
678 WSADATA WsaData;
679 int i;
680
681 /* Initialize the Console Standard Streams */
683
684 WSAStartup(MAKEWORD(2, 2), &WsaData);
685
686 for (i = 1; i < argc; ++i)
687 {
688 if (!wcscmp(argv[i], L"/?") || !wcscmp(argv[i], L"-?"))
689 {
690 Usage();
691 return 0;
692 }
693 else
694 {
695 ConPrintf(StdErr, L"Unsupported argument: %s\n", argv[i]);
696 return -1;
697 }
698 }
699
700 AllSysInfo();
701
702 return 0;
703}
static int argc
Definition: ServiceArgs.c:12
#define ConInitStdStreams()
Definition: fc.c:13
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
Definition: hidpi.h:384
VOID AllSysInfo(VOID)
Definition: systeminfo.c:257
#define argv
Definition: mplay32.c:18
#define MAKEWORD(a, b)
Definition: typedefs.h:248