ReactOS  0.4.14-dev-114-gc8cbd56
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 "resource.h"
Include dependency graph for systeminfo.c:

Go to the source code of this file.

Macros

#define BUFFER_SIZE   1024
 

Functions

static unsigned 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, unsigned 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 main (int argc, char *argv[])
 

Macro Definition Documentation

◆ BUFFER_SIZE

#define BUFFER_SIZE   1024

Definition at line 34 of file systeminfo.c.

Function Documentation

◆ AllSysInfo()

VOID AllSysInfo ( VOID  )

Definition at line 269 of file systeminfo.c.

270 {
271  DWORD dwCharCount = BUFFER_SIZE, dwTimestamp, dwResult;
272  OSVERSIONINFOW VersionInfo;
273  SYSTEM_INFO SysInfo;
274  WCHAR Buf[BUFFER_SIZE], Tmp[BUFFER_SIZE], szSystemDir[MAX_PATH];
275  const WCHAR *lpcszSysType;
277  NETSETUP_JOIN_STATUS NetJoinStatus;
278  MEMORYSTATUS MemoryStatus;
279  unsigned int cSeconds, i, j;
280  TIME_ZONE_INFORMATION TimeZoneInfo;
281  HKEY hKey;
282  PIP_ADAPTER_ADDRESSES pAdapters;
283  ULONG cbAdapters;
284  PVOID SMBiosBuf;
285  PCHAR DmiStrings[ID_STRINGS_MAX] = { 0 };
286 
287  if (!GetSystemDirectoryW(szSystemDir, sizeof(szSystemDir)/sizeof(szSystemDir[0])))
288  {
289  wprintf(L"Error! GetSystemDirectory failed.\n");
290  return;
291  }
292 
293  GetSystemInfo(&SysInfo);
294 
295  // getting computer name
296  dwCharCount = BUFFER_SIZE;
297  if (!GetComputerNameW(Buf, &dwCharCount))
298  wprintf(L"Error! GetComputerName failed.\n");
299  else
300  PrintRow(IDS_HOST_NAME, FALSE, L"%s", Buf);
301 
302  // open CurrentVersion key
304  L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
305  0,
307  &hKey) != ERROR_SUCCESS)
308  {
309  wprintf(L"Error! RegOpenKeyEx failed.\n");
310  return;
311  }
312 
313  //getting OS Name
314  RegGetSZ(hKey, NULL, L"ProductName", Buf, BUFFER_SIZE);
315  PrintRow(IDS_OS_NAME, FALSE, L"%s", Buf);
316 
317  //getting OS Version
318  ZeroMemory(&VersionInfo, sizeof(VersionInfo));
319  VersionInfo.dwOSVersionInfoSize = sizeof(VersionInfo);
320  GetVersionExW(&VersionInfo);
321 
323  Tmp[0] = L'\0';
325  FALSE,
326  L"%lu.%lu.%lu %s %s %lu",
327  VersionInfo.dwMajorVersion,
328  VersionInfo.dwMinorVersion,
329  VersionInfo.dwBuildNumber,
330  VersionInfo.szCSDVersion,
331  Tmp,
332  VersionInfo.dwBuildNumber);
333 
334  //getting OS Manufacturer
335 
336  //getting OS Configuration
337 
338  //getting OS Build Type
339  RegGetSZ(hKey, NULL, L"CurrentType", Buf, BUFFER_SIZE);
340  PrintRow(IDS_OS_BUILD_TYPE, FALSE, L"%s", Buf);
341 
342  //getting Registered Owner
343  RegGetSZ(hKey, NULL, L"RegisteredOwner", Buf, BUFFER_SIZE);
344  PrintRow(IDS_REG_OWNER, FALSE, L"%s", Buf);
345 
346  //getting Registered Organization
347  RegGetSZ(hKey, NULL, L"RegisteredOrganization", Buf, BUFFER_SIZE);
348  PrintRow(IDS_REG_ORG, FALSE, L"%s", Buf);
349 
350  //getting Product ID
351  RegGetSZ(hKey, NULL, L"ProductId", Buf, BUFFER_SIZE);
352  PrintRow(IDS_PRODUCT_ID, FALSE, L"%s", Buf);
353 
354  //getting Install Date
355  RegGetDWORD(hKey, NULL, L"InstallDate", &dwTimestamp);
356  FormatDateTime((time_t)dwTimestamp, Buf);
357  PrintRow(IDS_INST_DATE, FALSE, L"%s", Buf);
358 
359  // close Current Version key now
360  RegCloseKey(hKey);
361 
362  //getting System Up Time
363  cSeconds = GetSeconds();
365  Tmp[0] = L'\0';
366  swprintf(Buf, Tmp, cSeconds / (60*60*24), (cSeconds / (60*60)) % 24, (cSeconds / 60) % 60, cSeconds % 60);
367  PrintRow(IDS_UP_TIME, FALSE, L"%s", Buf);
368 
369  // prepare SMBIOS data
370  SMBiosBuf = LoadSMBiosData(DmiStrings);
371 
372  //getting System Manufacturer; HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation\Manufacturer for Win >= 6.0
373  swprintf(Tmp, L"%s\\oeminfo.ini", szSystemDir);
374  GetPrivateProfileStringW(L"General",
375  L"Manufacturer",
376  L"",
377  Buf,
378  sizeof(Buf)/sizeof(Buf[0]),
379  Tmp);
380  if (wcslen(Buf) == 0 && SMBiosBuf)
381  {
382  GetSMBiosStringW(DmiStrings[SYS_VENDOR], Buf, _countof(Buf), FALSE);
383  }
384  PrintRow(IDS_SYS_MANUFACTURER, FALSE, L"%s", Buf);
385 
386  //getting System Model; HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation\Model for Win >= 6.0
387  GetPrivateProfileStringW(L"General",
388  L"Model",
389  L"",
390  Buf,
391  sizeof(Buf)/sizeof(Buf[0]),
392  Tmp);
393  if (wcslen(Buf) == 0 && SMBiosBuf)
394  {
395  GetSMBiosStringW(DmiStrings[SYS_PRODUCT], Buf, _countof(Buf), FALSE);
396  }
397  PrintRow(IDS_SYS_MODEL, FALSE, L"%s", Buf);
398 
399  //getting System type
400  switch (SysInfo.wProcessorArchitecture)
401  {
403  lpcszSysType = L"X86-based PC";
404  break;
406  lpcszSysType = L"IA64-based PC";
407  break;
409  lpcszSysType = L"AMD64-based PC";
410  break;
411  default:
412  lpcszSysType = L"Unknown";
413  break;
414  }
415  PrintRow(IDS_SYS_TYPE, FALSE, L"%s", lpcszSysType);
416 
417  //getting Processor(s)
419  Tmp[0] = L'\0';
420  swprintf(Buf, Tmp, (unsigned)SysInfo.dwNumberOfProcessors);
421  PrintRow(IDS_PROCESSORS, FALSE, L"%s", Buf);
422  for(i = 0; i < (unsigned int)SysInfo.dwNumberOfProcessors; i++)
423  {
424  swprintf(Tmp, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u", i);
425  j = swprintf(Buf, L"[%02u]: ", i + 1);
426 
427  j += RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"Identifier", Buf + j, BUFFER_SIZE - j);
428  if(j + 1 < BUFFER_SIZE)
429  Buf[j++] = L' ';
430  RegGetSZ(HKEY_LOCAL_MACHINE, Tmp, L"VendorIdentifier", Buf + j, BUFFER_SIZE - j);
431 
432  PrintRow(0, FALSE, L"%s", Buf);
433  }
434 
435  //getting BIOS Version
436  if (SMBiosBuf)
437  {
438  j = GetSMBiosStringW(DmiStrings[BIOS_VENDOR], Buf, BUFFER_SIZE, TRUE);
439  if (j + 1 < BUFFER_SIZE)
440  {
441  Buf[j++] = L' ';
442  Buf[j] = L'\0';
443  }
444  GetSMBiosStringW(DmiStrings[BIOS_VERSION], Buf + j, BUFFER_SIZE - j, TRUE);
445  }
446  else
447  {
449  L"HARDWARE\\DESCRIPTION\\System",
450  L"SystemBiosVersion",
451  Buf,
452  BUFFER_SIZE);
453  }
454  PrintRow(IDS_BIOS_VERSION, FALSE, L"%s", Buf);
455 
456  //gettings BIOS date
457  if (SMBiosBuf)
458  {
459  GetSMBiosStringW(DmiStrings[BIOS_DATE], Buf, BUFFER_SIZE, TRUE);
460  }
461  else
462  {
464  L"HARDWARE\\DESCRIPTION\\System",
465  L"SystemBiosDate",
466  Buf,
467  BUFFER_SIZE);
468  }
469  PrintRow(IDS_BIOS_DATE, FALSE, L"%s", Buf);
470 
471  // clean SMBIOS data
472  FreeSMBiosData(SMBiosBuf);
473 
474  //getting ReactOS Directory
476  wprintf(L"Error! GetWindowsDirectory failed.");
477  else
478  PrintRow(IDS_ROS_DIR, FALSE, L"%s", Buf);
479 
480  //getting System Directory
481  PrintRow(IDS_SYS_DIR, 0, L"%s", szSystemDir);
482 
483  //getting Boot Device
485  L"SYSTEM\\Setup",
486  L"SystemPartition",
487  Buf,
488  BUFFER_SIZE);
489  PrintRow(IDS_BOOT_DEV, FALSE, L"%s", Buf);
490 
491  //getting System Locale
494  L"MIME\\Database\\Rfc1766",
495  Tmp,
496  Buf,
497  BUFFER_SIZE))
498  {
499  /* get rid of @filename,resource */
500  lpBuffer = wcschr(Buf, L';');
501  if (lpBuffer)
503 
504  PrintRow(IDS_SYS_LOCALE, FALSE, L"%s", Buf);
505  }
506 
507  //getting Input Locale
509  L"Keyboard Layout\\Preload",
510  L"1",
511  Tmp,
512  BUFFER_SIZE) && wcslen(Tmp) > 4)
514  L"MIME\\Database\\Rfc1766",
515  Tmp + 4,
516  Buf,
517  BUFFER_SIZE))
518  {
519  /* get rid of @filename,resource */
520  lpBuffer = wcschr(Buf, L';');
521  if (lpBuffer)
523 
524  PrintRow(IDS_INPUT_LOCALE, FALSE, L"%s", Buf);
525  }
526 
527  //getting Time Zone
528  GetTimeZoneInformation(&TimeZoneInfo);
529 
530  /* Open Time Zones key */
532  L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones",
533  0,
535  &hKey) == ERROR_SUCCESS)
536  {
537  unsigned i;
538 
539  /* Find current timezone */
540  dwCharCount = BUFFER_SIZE;
541  for(i = 0; RegEnumKeyExW(hKey, i, Tmp, &dwCharCount, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; ++i, dwCharCount = 255)
542  {
543  RegGetSZ(hKey, Tmp, L"Std", Buf, BUFFER_SIZE);
544 
545  if (!wcscmp(Buf, TimeZoneInfo.StandardName))
546  {
547  RegGetSZ(hKey, Tmp, L"Display", Buf, BUFFER_SIZE);
548 
549  PrintRow(IDS_TIME_ZONE, FALSE, L"%s", Buf);
550 
551  break;
552  }
553  }
554  RegCloseKey(hKey);
555  }
556 
557  //getting Total Physical Memory
558  GlobalMemoryStatus(&MemoryStatus);
559  FormatBytes(Buf, MemoryStatus.dwTotalPhys);
560  PrintRow(IDS_TOTAL_PHYS_MEM, FALSE, L"%s", Buf);
561 
562  //getting Available Physical Memory
563  FormatBytes(Buf, MemoryStatus.dwAvailPhys);
565 
566  //getting Virtual Memory: Max Size
567  FormatBytes(Buf, MemoryStatus.dwTotalVirtual);
568  PrintRow(IDS_VIRT_MEM_MAX, FALSE, L"%s", Buf);
569 
570  //getting Virtual Memory: Available
571  FormatBytes(Buf, MemoryStatus.dwAvailVirtual);
572  PrintRow(IDS_VIRT_MEM_AVAIL, FALSE, L"%s", Buf);
573 
574  //getting Virtual Memory: In Use
575  FormatBytes(Buf, MemoryStatus.dwTotalVirtual-MemoryStatus.dwAvailVirtual);
576  PrintRow(IDS_VIRT_MEM_INUSE, FALSE, L"%s", Buf);
577 
578  //getting Page File Location(s)
580  L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management",
581  L"PagingFiles",
582  Buf,
583  BUFFER_SIZE))
584  {
585  int i;
586 
587  for(i = 0; Buf[i]; i++)
588  {
589  if (Buf[i] == L' ')
590  {
591  Buf[i] = L'\0';
592  break;
593  }
594  }
595 
596  PrintRow(IDS_PAGEFILE_LOC, FALSE, L"%s", Buf);
597  }
598 
599  //getting Domain
600  if (NetGetJoinInformation (NULL, &lpBuffer, &NetJoinStatus) == NERR_Success)
601  {
602  if (NetJoinStatus == NetSetupWorkgroupName || NetJoinStatus == NetSetupDomainName)
604 
606  }
607 
608  //getting Logon Server
609 
610  //getting NetWork Card(s)
611  cbAdapters = 4096;
612  pAdapters = malloc(cbAdapters);
613  while((dwResult = GetAdaptersAddresses(AF_UNSPEC, 0x0002, NULL, pAdapters, &cbAdapters)) == ERROR_BUFFER_OVERFLOW)
614  {
615  cbAdapters += 4096;
616  pAdapters = (PIP_ADAPTER_ADDRESSES)realloc(pAdapters, cbAdapters);
617  }
618 
619  if (dwResult == ERROR_SUCCESS)
620  {
621  PIP_ADAPTER_ADDRESSES pCurrentAdapter = pAdapters;
622  unsigned cAdapters = 0;
623 
624  /* Count adapters */
625  for(i = 0; pCurrentAdapter; ++i)
626  {
627  if (pCurrentAdapter->IfType != 24 && pCurrentAdapter->IfType != 131)
628  ++cAdapters;
629  pCurrentAdapter = pCurrentAdapter->Next;
630  }
631 
632 
633  /* Print adapters count */
635  Tmp[0] = L'\0';
636  swprintf(Buf, Tmp, cAdapters);
637  PrintRow(IDS_NETWORK_CARDS, FALSE, L"%s", Buf);
638 
639  /* Show information about each adapter */
640  pCurrentAdapter = pAdapters;
641  for(i = 0; pCurrentAdapter; ++i)
642  {
643  if (pCurrentAdapter->IfType != 24 && pCurrentAdapter->IfType != 131)//IF_TYPE_SOFTWARE_LOOPBACK)
644  {
645  PIP_ADAPTER_UNICAST_ADDRESS pAddress;
646 
647  PrintRow(0, FALSE, L"[%02u]: %s", i + 1, pCurrentAdapter->Description);
648  PrintRow(IDS_CONNECTION_NAME, TRUE, L"%s", pCurrentAdapter->FriendlyName);
649  if (!(pCurrentAdapter->Flags & 0x0004))
650  {
652  Buf[0] = L'\0';
654  }
655  if (pCurrentAdapter->OperStatus == IfOperStatusDown)
656  {
658  Buf[0] = L'\0';
659  PrintRow(IDS_STATUS, TRUE, Buf);
660  }
661  else
662  {
664  Buf[0] = L'\0';
665  PrintRow(0, TRUE, Buf);
666  pAddress = pCurrentAdapter->FirstUnicastAddress;
667  for (j = 0; pAddress; ++j)
668  {
669  dwCharCount = BUFFER_SIZE;
670  WSAAddressToStringW(pAddress->Address.lpSockaddr, pAddress->Address.iSockaddrLength, NULL, Buf, &dwCharCount);
671  PrintRow(0, TRUE, L"[%02u]: %s", j + 1, Buf);
672  pAddress = pAddress->Next;
673  }
674  }
675  }
676  pCurrentAdapter = pCurrentAdapter->Next;
677  }
678  }
679  free(pAdapters);
680 }
#define realloc
Definition: debug_ros.c:6
#define IDS_MEDIA_DISCONNECTED
Definition: resource.h:40
signed char * PCHAR
Definition: retypes.h:7
DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
Definition: timezone.c:262
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
#define TRUE
Definition: types.h:120
#define IDS_OS_VERSION
Definition: resource.h:155
#define ERROR_SUCCESS
Definition: deptool.c:10
INT WSAAPI WSAAddressToStringW(IN LPSOCKADDR lpsaAddress, IN DWORD dwAddressLength, IN LPWSAPROTOCOL_INFOW lpProtocolInfo, OUT LPWSTR lpszAddressString, IN OUT LPDWORD lpdwAddressStringLength)
Definition: rnr.c:128
#define IDS_VIRT_MEM_MAX
Definition: resource.h:30
#define IDS_STATUS
Definition: resource.h:22
#define IDS_REG_ORG
Definition: resource.h:11
static BOOL RegGetDWORD(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPDWORD lpData)
Definition: systeminfo.c:91
ULONGLONG GetSeconds(VOID)
Definition: systeminfo.c:191
#define IDS_OS_NAME
Definition: resource.h:6
#define KEY_READ
Definition: nt_native.h:1023
#define BUFFER_SIZE
Definition: systeminfo.c:34
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
#define _countof(array)
Definition: fontsub.cpp:30
#define IDS_VIRT_MEM_INUSE
Definition: resource.h:32
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define free
Definition: debug_ros.c:5
#define IDS_BIOS_VERSION
Definition: resource.h:22
WCHAR szCSDVersion[128]
Definition: rtltypes.h:247
#define IDS_DOMAIN
Definition: resource.h:35
#define ZeroMemory
Definition: winbase.h:1642
#define LOCALE_ILANGUAGE
Definition: winnls.h:25
NET_API_STATUS NET_API_FUNCTION NetGetJoinInformation(LPCWSTR Server, LPWSTR *Name, PNETSETUP_JOIN_STATUS type)
Definition: wksta.c:559
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:440
#define wprintf(...)
Definition: whoami.c:18
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
Definition: version.c:37
SIZE_T GetSMBiosStringW(_In_ PCSTR DmiString, _Out_ PWSTR pBuf, _In_ DWORD cchBuf, _In_ BOOL bTrim)
Definition: udmihelp.c:145
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
SIZE_T dwAvailVirtual
Definition: winbase.h:1183
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
#define NERR_Success
Definition: lmerr.h:5
#define PROCESSOR_ARCHITECTURE_IA64
Definition: ketypes.h:111
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
#define IDS_NETWORK_CARDS_FORMAT
Definition: resource.h:37
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
SIZE_T dwAvailPhys
Definition: winbase.h:1179
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
#define IDS_ROS_DIR
Definition: resource.h:23
#define IDS_NO
Definition: resource.h:17
#define IDS_SYS_LOCALE
Definition: resource.h:26
#define IDS_TOTAL_PHYS_MEM
Definition: resource.h:28
#define AF_UNSPEC
Definition: winsock.h:344
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
#define IDS_NETWORK_CARDS
Definition: resource.h:36
#define IDS_DHCP_ENABLED
Definition: resource.h:41
SIZE_T dwTotalVirtual
Definition: winbase.h:1182
ULONG dwMajorVersion
Definition: rtltypes.h:243
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
enum tagNETSETUP_JOIN_STATUS NETSETUP_JOIN_STATUS
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:242
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define IDS_AVAIL_PHISICAL_MEM
Definition: resource.h:29
#define LOCALE_SYSTEM_DEFAULT
#define IDS_SYS_MODEL
Definition: resource.h:17
static VOID PrintRow(UINT nTitleID, BOOL bIndent, LPWSTR lpFormat,...)
Definition: systeminfo.c:237
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDS_SYS_MANUFACTURER
Definition: resource.h:16
VOID NTAPI GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer)
Definition: heapmem.c:1348
#define IDS_TIME_ZONE
Definition: resource.h:34
#define PROCESSOR_ARCHITECTURE_AMD64
Definition: ketypes.h:114
static VOID FormatBytes(LPWSTR lpBuf, unsigned cBytes)
Definition: systeminfo.c:130
ULONG dwBuildNumber
Definition: rtltypes.h:245
static const WCHAR L[]
Definition: oid.c:1250
#define IDS_SYS_TYPE
Definition: resource.h:18
#define IDS_SYS_DIR
Definition: resource.h:24
HRESULT WINAPI SHLoadIndirectString(LPCWSTR src, LPWSTR dst, UINT dst_len, void **reserved)
Definition: string.c:2842
#define PROCESSOR_ARCHITECTURE_INTEL
Definition: ketypes.h:105
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define IDS_REG_OWNER
Definition: resource.h:10
#define IDS_INST_DATE
Definition: resource.h:13
#define IDS_HOST_NAME
Definition: resource.h:5
#define IDS_PROCESSORS
Definition: resource.h:19
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
#define GetModuleHandle
Definition: winbase.h:3651
static unsigned RegGetSZ(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpValueName, LPWSTR lpBuf, DWORD cchBuf)
Definition: systeminfo.c:39
#define IDS_VIRT_MEM_AVAIL
Definition: resource.h:31
__kernel_time_t time_t
Definition: linux.h:252
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
VOID FreeSMBiosData(_In_ PVOID Buffer)
Definition: udmihelp.c:177
#define IDS_INPUT_LOCALE
Definition: resource.h:27
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:142
#define IDS_UP_TIME_FORMAT
Definition: resource.h:15
#define IDS_UP_TIME
Definition: resource.h:14
#define IDS_PROCESSORS_FORMAT
Definition: resource.h:20
#define IDS_BUILD
Definition: resource.h:8
WORD wProcessorArchitecture
Definition: winbase.h:1129
#define IDS_OS_BUILD_TYPE
Definition: resource.h:9
ULONG dwMinorVersion
Definition: rtltypes.h:244
DWORD dwNumberOfProcessors
Definition: winbase.h:1137
static VOID FormatDateTime(time_t Time, LPWSTR lpBuf)
Definition: systeminfo.c:154
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
PVOID LoadSMBiosData(_Inout_updates_(ID_STRINGS_MAX) PCHAR *Strings)
Definition: udmihelp.c:30
#define malloc
Definition: debug_ros.c:4
#define IDS_IP_ADDRESSES
Definition: resource.h:43
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
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:2527
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDS_BOOT_DEV
Definition: resource.h:25
#define IDS_CONNECTION_NAME
Definition: resource.h:38
static PIP_ADAPTER_ADDRESSES
Definition: iphlpapi.c:76
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
WCHAR StandardName[32]
Definition: winbase.h:1167
#define IDS_BIOS_DATE
Definition: resource.h:21
SIZE_T dwTotalPhys
Definition: winbase.h:1178
#define IDS_PAGEFILE_LOC
Definition: resource.h:33
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define IDS_PRODUCT_ID
Definition: resource.h:12
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019

Referenced by main().

◆ FormatBytes()

static VOID FormatBytes ( LPWSTR  lpBuf,
unsigned  cBytes 
)
static

Definition at line 130 of file systeminfo.c.

131 {
132  WCHAR szMB[32];
133  NUMBERFMTW fmt;
134  unsigned i;
135 
136  _itow(cBytes / (1024*1024), szMB, 10);
137 
138  fmt.NumDigits = 0;
139  fmt.LeadingZero = 0;
140  fmt.Grouping = 3;
141  fmt.lpDecimalSep = L"";
142  fmt.lpThousandSep = L" ";
143  fmt.NegativeOrder = 0;
144 
145  i = GetNumberFormatW(LOCALE_SYSTEM_DEFAULT, 0, szMB, &fmt, lpBuf, BUFFER_SIZE - 3);
146  if (i)
147  --i; /* don't count NULL character */
148  wcscpy(lpBuf + i, L" MB");
149 }
#define BUFFER_SIZE
Definition: systeminfo.c:34
const char * fmt
Definition: wsprintf.c:30
_CRTIMP wchar_t *__cdecl _itow(_In_ int _Value, _Pre_notnull_ _Post_z_ wchar_t *_Dest, _In_ int _Radix)
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define LOCALE_SYSTEM_DEFAULT
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1198
Definition: dsound.c:943

Referenced by AllSysInfo().

◆ FormatDateTime()

static VOID FormatDateTime ( time_t  Time,
LPWSTR  lpBuf 
)
static

Definition at line 154 of file systeminfo.c.

155 {
156  unsigned i;
157  SYSTEMTIME SysTime;
158  const struct tm *lpTm;
159 
160  lpTm = localtime(&Time);
161  SysTime.wYear = (WORD)(1900 + lpTm->tm_year);
162  SysTime.wMonth = (WORD)(1 + lpTm->tm_mon);
163  SysTime.wDayOfWeek = (WORD)lpTm->tm_wday;
164  SysTime.wDay = (WORD)lpTm->tm_mday;
165  SysTime.wHour = (WORD)lpTm->tm_hour;
166  SysTime.wMinute = (WORD)lpTm->tm_min;
167  SysTime.wSecond = (WORD)lpTm->tm_sec;
168  SysTime.wMilliseconds = 0;
169 
170  /* Copy date first */
171  i = GetDateFormatW(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf, BUFFER_SIZE - 2);
172  if (i)
173  --i; /* don't count NULL character */
174 
175  /* Copy time now */
176  i += swprintf(lpBuf + i, L", ");
177 
178  GetTimeFormatW(LOCALE_SYSTEM_DEFAULT, 0, &SysTime, NULL, lpBuf + i, BUFFER_SIZE - i);
179 }
int tm_min
Definition: time.h:78
WORD wMonth
Definition: winbase.h:878
#define BUFFER_SIZE
Definition: systeminfo.c:34
WORD wDayOfWeek
Definition: winbase.h:879
int tm_mday
Definition: time.h:80
int tm_year
Definition: time.h:82
WORD wYear
Definition: winbase.h:877
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
WORD wMinute
Definition: winbase.h:882
smooth NULL
Definition: ftsmooth.c:416
int tm_mon
Definition: time.h:81
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define LOCALE_SYSTEM_DEFAULT
unsigned short WORD
Definition: ntddk_ex.h:93
WORD wSecond
Definition: winbase.h:883
WORD wMilliseconds
Definition: winbase.h:884
static const WCHAR L[]
Definition: oid.c:1250
Definition: time.h:76
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:424
int tm_wday
Definition: time.h:83
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:979
WORD wDay
Definition: winbase.h:880
WORD wHour
Definition: winbase.h:881
int tm_sec
Definition: time.h:77
int tm_hour
Definition: time.h:79
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1079
static PLARGE_INTEGER Time
Definition: time.c:105

Referenced by AllSysInfo().

◆ GetSeconds()

ULONGLONG GetSeconds ( VOID  )

Definition at line 191 of file systeminfo.c.

192 {
193  ULONGLONG (WINAPI * pGetTickCount64)(VOID);
194  ULONGLONG Ticks64;
195  HMODULE hModule = GetModuleHandleW(L"kernel32.dll");
196 
197  pGetTickCount64 = (PVOID)GetProcAddress(hModule, "GetTickCount64");
198  if (pGetTickCount64)
199  {
200  return pGetTickCount64() / 1000;
201  }
202 
203  hModule = LoadLibraryW(L"kernel32_vista.dll");
204 
205  if (!hModule)
206  {
207  return GetSecondsQPC();
208  }
209 
210  pGetTickCount64 = (PVOID)GetProcAddress(hModule, "GetTickCount64");
211 
212  if (pGetTickCount64)
213  {
214  Ticks64 = pGetTickCount64() / 1000;
215  }
216  else
217  {
218  Ticks64 = GetSecondsQPC();
219  }
220 
222  return Ticks64;
223 }
ULONGLONG GetSecondsQPC(VOID)
Definition: systeminfo.c:181
#define LoadLibraryW(x)
Definition: compat.h:404
void * PVOID
Definition: retypes.h:9
#define FreeLibrary(x)
Definition: compat.h:405
uint64_t ULONGLONG
Definition: typedefs.h:65
#define WINAPI
Definition: msvc.h:8
static const WCHAR L[]
Definition: oid.c:1250
#define VOID
Definition: acefi.h:82
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:847
#define GetProcAddress(x, y)
Definition: compat.h:410
HMODULE hModule
Definition: animate.c:44

Referenced by AllSysInfo().

◆ GetSecondsQPC()

ULONGLONG GetSecondsQPC ( VOID  )

Definition at line 181 of file systeminfo.c.

182 {
184 
187 
189 }
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:112

Referenced by GetSeconds().

◆ main()

int main ( int argc  ,
char argv[] 
)

hosttype.c Copyright (C) 2002 by Brian Palmer brian.nosp@m.p@sg.nosp@m.inet..nosp@m.com

Definition at line 684 of file systeminfo.c.

685 {
686  WSADATA WsaData;
687  int i;
688 
689  setlocale(LC_ALL, "");
690 
691  WSAStartup(MAKEWORD(2, 2), &WsaData);
692 
693  for (i = 1; i < argc; ++i)
694  {
695  if (!strcmp(argv[i], "/?") || !strcmp(argv[i], "-?"))
696  {
697  Usage();
698  return 0;
699  }
700  else
701  {
702  printf("Unsupported argument: %s\n", argv[i]);
703  return -1;
704  }
705  }
706 
707  AllSysInfo();
708 
709  return 0;
710 }
static int argc
Definition: ServiceArgs.c:12
#define MAKEWORD(a, b)
Definition: typedefs.h:247
#define argv
Definition: mplay32.c:18
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
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
VOID AllSysInfo(VOID)
Definition: systeminfo.c:269
#define LC_ALL
Definition: locale.h:25
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define setlocale(n, s)
Definition: locale.h:46
static VOID Usage(VOID)
Definition: systeminfo.c:228
#define printf
Definition: config.h:203

◆ PrintRow()

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

Definition at line 237 of file systeminfo.c.

238 {
239  WCHAR Buf[BUFFER_SIZE];
240  va_list Args;
241  unsigned c;
242 
243  if (nTitleID)
244  {
245  c = LoadStringW(GetModuleHandle(NULL), nTitleID, Buf, BUFFER_SIZE - 2);
246  if (!c)
247  return;
248 
249  wcscpy(Buf + c, L": ");
250  } else
251  Buf[0] = L'\0';
252 
253  if (!bIndent)
254  wprintf(L"%-32s", Buf);
255  else if (Buf[0])
256  wprintf(L"%38s%-16s", L"", Buf);
257  else
258  wprintf(L"%38s", L"");
259 
262  va_end(Args);
263 
264  wprintf(L"\n");
265 }
#define BUFFER_SIZE
Definition: systeminfo.c:34
#define wprintf(...)
Definition: whoami.c:18
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define va_end(ap)
Definition: acmsvcex.h:90
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
char ** Args
Definition: acdebug.h:343
_Check_return_opt_ _CRTIMP int __cdecl vwprintf(_In_z_ _Printf_format_string_ const wchar_t *_Format, va_list _ArgList)
__wchar_t WCHAR
Definition: xmlstorage.h:180
const GLubyte * c
Definition: glext.h:8905
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
LPCWSTR lpFormat
Definition: trayclock.cpp:32
#define GetModuleHandle
Definition: winbase.h:3651
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define c
Definition: ke_i.h:80

Referenced by AllSysInfo().

◆ RegGetDWORD()

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

Definition at line 91 of file systeminfo.c.

92 {
93  DWORD dwBytes = sizeof(*lpData), dwType;
94  BOOL bRet = TRUE;
95 
96  /* If SubKey is specified open it */
97  if (lpSubKey && RegOpenKeyExW(hKey,
98  lpSubKey,
99  0,
101  &hKey) != ERROR_SUCCESS)
102  {
103  wprintf(L"Warning! Cannot open %s. Last error: %lu.\n", lpSubKey, GetLastError());
104  return FALSE;
105  }
106 
107  /* Query registry value and check its type */
108  if (RegQueryValueExW(hKey,
109  lpValueName,
110  NULL,
111  &dwType,
112  (LPBYTE)lpData,
113  &dwBytes) != ERROR_SUCCESS || dwType != REG_DWORD)
114  {
115  wprintf(L"Warning! Cannot query %s. Last err: %lu, type: %lu\n", lpValueName, GetLastError(), dwType);
116  *lpData = 0;
117  bRet = FALSE;
118  }
119 
120  /* Close key if we opened it */
121  if (lpSubKey)
122  RegCloseKey(hKey);
123 
124  return bRet;
125 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define wprintf(...)
Definition: whoami.c:18
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by AllSysInfo().

◆ RegGetSZ()

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

Definition at line 39 of file systeminfo.c.

40 {
41  DWORD dwBytes = cchBuf*sizeof(WCHAR), dwType = 0;
42  unsigned cChars;
43 
44  /* If SubKey is specified open it */
45  if (lpSubKey && RegOpenKeyExW(hKey,
46  lpSubKey,
47  0,
49  &hKey) != ERROR_SUCCESS)
50  {
51  wprintf(L"Warning! Cannot open %s. Last error: %lu.\n", lpSubKey, GetLastError());
52  return 0;
53  }
54 
55  /* Query registry value and check its type */
56  if (RegQueryValueExW(hKey,
57  lpValueName,
58  NULL,
59  &dwType,
60  (LPBYTE)lpBuf,
61  &dwBytes) != ERROR_SUCCESS || (dwType != REG_SZ && dwType != REG_MULTI_SZ))
62  {
63  wprintf(L"Warning! Cannot query %s. Last error: %lu, type: %lu.\n", lpValueName, GetLastError(), dwType);
64  dwBytes = 0;
65  }
66  else if (dwBytes == 0)
67  {
68  wcscpy(lpBuf, L"N/A");
69  dwBytes = 6;
70  }
71 
72  /* Close key if we opened it */
73  if (lpSubKey)
74  RegCloseKey(hKey);
75 
76  cChars = dwBytes/sizeof(WCHAR);
77 
78  /* NULL-terminate string */
79  lpBuf[min(cchBuf-1, cChars)] = L'\0';
80 
81  /* Don't count NULL characters */
82  while(cChars && !lpBuf[cChars-1])
83  --cChars;
84 
85  return cChars;
86 }
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define wprintf(...)
Definition: whoami.c:18
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define REG_MULTI_SZ
Definition: nt_native.h:1501
smooth NULL
Definition: ftsmooth.c:416
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG int TEXTRANGE_PROPERTIES int const WCHAR int cChars
Definition: usp10.c:64
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define min(a, b)
Definition: monoChain.cc:55
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define REG_SZ
Definition: layer.c:22

Referenced by AllSysInfo().

◆ Usage()

static VOID Usage ( VOID  )
static

Definition at line 228 of file systeminfo.c.

229 {
230  WCHAR Buf[4096];
231  if (LoadStringW(GetModuleHandle(NULL), IDS_USAGE, Buf, 4096))
232  wprintf(L"%s", Buf);
233 }
#define IDS_USAGE
Definition: resource.h:3
#define wprintf(...)
Definition: whoami.c:18
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
#define GetModuleHandle
Definition: winbase.h:3651

Referenced by main().