2 This program is free software; you can redistribute it and/or modify
3 it under the terms of the GNU General Public License as published by
4 the Free Software Foundation; either version 2 of the License, or
5 (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 /* Copyright (C) 2007, Dmitry Chapyshev <lentind@yandex.ru> */
27 #define BUFFER_SIZE 32767
29 /* Load from resource and convert to OEM */
32 GetOemStrings(UINT rcID
, LPSTR OutMsg
)
34 TCHAR Msg
[BUFFER_SIZE
];
35 if (LoadString(GetModuleHandle(NULL
), rcID
, (LPTSTR
)Msg
, BUFFER_SIZE
))
37 CharToOem(Msg
, OutMsg
);
43 /* Load data from registry */
46 GetRegistryValue(HKEY hKeyName
, LPCTSTR SubKey
, LPCTSTR ValueName
, LPCTSTR Buf
)
48 DWORD CharCount
= BUFFER_SIZE
;
52 CharCount
= BUFFER_SIZE
;
53 lRet
= RegOpenKeyEx(hKeyName
,
58 if (lRet
!= ERROR_SUCCESS
) return FALSE
;
59 lRet
= RegQueryValueEx(hKey
,
65 if (lRet
!= ERROR_SUCCESS
) return FALSE
;
74 TCHAR Buf
[BUFFER_SIZE
];
75 if(GetOemStrings(IDS_USAGE
,Buf
)) printf("%s",Buf
);
78 /* Print all system information */
82 DWORD CharCount
= BUFFER_SIZE
;
83 OSVERSIONINFO VersionInfo
;
84 BOOL bOsVersionInfoEx
;
86 TCHAR Buf
[BUFFER_SIZE
],Tmp
[BUFFER_SIZE
], Msg
[BUFFER_SIZE
];
88 unsigned int DIV
= 1024;
90 GetSystemInfo(&SysInfo
);
92 // getting computer name
93 CharCount
= BUFFER_SIZE
;
94 if(!GetComputerName(Buf
,&CharCount
)) printf("Error getting: GetComputerName");
95 if(GetOemStrings(IDS_HOST_NAME
,Msg
)) fprintf(stderr
,Msg
,Buf
);
98 GetRegistryValue(HKEY_LOCAL_MACHINE
,
99 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
102 if(GetOemStrings(IDS_OS_NAME
,Msg
)) fprintf(stderr
,Msg
,Buf
);
105 ZeroMemory(&VersionInfo
, sizeof(OSVERSIONINFO
));
106 VersionInfo
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
107 if(!(bOsVersionInfoEx
= GetVersionEx((OSVERSIONINFO
*)&VersionInfo
)))
109 VersionInfo
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
110 if (!GetVersionEx((OSVERSIONINFO
*)&VersionInfo
))
113 if (VersionInfo
.dwPlatformId
== VER_PLATFORM_WIN32_NT
)
115 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
116 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
119 if(GetOemStrings(IDS_OS_VERSION
,Msg
))
121 (int)VersionInfo
.dwMajorVersion
,
122 (int)VersionInfo
.dwMinorVersion
,
123 (int)VersionInfo
.dwBuildNumber
,
125 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
126 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
127 TEXT("CurrentBuildNumber"),
129 if(GetOemStrings(IDS_OS_BUILD
,Msg
)) fprintf(stderr
,Msg
,Buf
);
132 //getting OS Manufacturer
134 //getting OS Configuration
136 //getting OS Build Type
137 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
138 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
141 if(GetOemStrings(IDS_OS_BUILD_TYPE
,Msg
)) fprintf(stderr
,Msg
,Buf
);
143 //getting Registered Owner
144 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
145 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
146 TEXT("RegisteredOwner"),
148 if(GetOemStrings(IDS_REG_OWNER
,Msg
)) fprintf(stderr
,Msg
,Buf
);
150 //getting Registered Organization
151 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
152 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
153 TEXT("RegisteredOrganization"),
155 if(GetOemStrings(IDS_REG_ORG
,Msg
)) fprintf(stderr
,Msg
,Buf
);
158 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
159 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
162 if(GetOemStrings(IDS_PRODUCT_ID
,Msg
)) fprintf(stderr
,Msg
,Buf
);
164 //getting Install Date
165 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
166 TEXT("SOFTWARE\\Microsoft\\WBEM\\CIMOM"),
169 if(GetOemStrings(IDS_INST_DATE
,Msg
)) fprintf(stderr
,Msg
,Buf
);
171 //getting Install Time
172 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
173 TEXT("SOFTWARE\\Microsoft\\WBEM\\CIMOM"),
176 if(GetOemStrings(IDS_INST_TIME
,Msg
)) fprintf(stderr
,Msg
,Buf
);
178 //getting System Up Time
180 //getting System Manufacturer
182 //getting System Model
184 //getting System type
185 switch (SysInfo
.wProcessorArchitecture
)
187 case PROCESSOR_ARCHITECTURE_UNKNOWN
:
188 if(GetOemStrings(IDS_SYS_TYPE_UNKNOWN
,Msg
)) printf("%s",Msg
);
190 case PROCESSOR_ARCHITECTURE_INTEL
:
191 if(GetOemStrings(IDS_SYS_TYPE_X86
,Msg
)) printf("%s",Msg
);
193 case PROCESSOR_ARCHITECTURE_IA64
:
194 if(GetOemStrings(IDS_SYS_TYPE_IA64
,Msg
)) printf("%s",Msg
);
196 case PROCESSOR_ARCHITECTURE_AMD64
:
197 if(GetOemStrings(IDS_SYS_TYPE_AMD64
,Msg
)) printf("%s",Msg
);
201 //getting Processor(s)
202 if(GetOemStrings(IDS_PROCESSORS
,Msg
))
204 fprintf(stderr
,Msg
,(unsigned int)SysInfo
.dwNumberOfProcessors
);
206 for(i
= 0; i
< (unsigned int)SysInfo
.dwNumberOfProcessors
; i
++)
208 sprintf(Tmp
,"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u",i
);
209 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
213 printf(" [0%u]: %s",i
+1,Buf
);
214 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
216 TEXT("VendorIdentifier"),
222 //getting BIOS Version
223 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
224 TEXT("HARDWARE\\DESCRIPTION\\System"),
225 TEXT("SystemBiosVersion"),
227 if(GetOemStrings(IDS_BIOS_VERSION
,Msg
)) fprintf(stderr
,Msg
,Buf
);
230 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
231 TEXT("HARDWARE\\DESCRIPTION\\System"),
232 TEXT("SystemBiosDate"),
234 if(GetOemStrings(IDS_BIOS_DATE
,Msg
)) fprintf(stderr
,Msg
,Buf
);
236 //getting ReactOS Directory
237 if(!GetWindowsDirectory(Buf
,BUFFER_SIZE
)) printf("Error getting: GetWindowsDirectory");
238 if(GetOemStrings(IDS_ROS_DIR
,Msg
)) fprintf(stderr
,Msg
,Buf
);
240 //getting System Directory
241 if(!GetSystemDirectory(Buf
,BUFFER_SIZE
)) printf("Error getting: GetSystemDirectory");
242 if(GetOemStrings(IDS_SYS_DIR
,Msg
)) fprintf(stderr
,Msg
,Buf
);
244 //getting Boot Device
245 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
246 TEXT("SYSTEM\\Setup"),
247 TEXT("SystemPartition"),
249 if(GetOemStrings(IDS_BOOT_DEV
,Msg
)) fprintf(stderr
,Msg
,Buf
);
251 //getting System Locale
252 if (GetRegistryValue(HKEY_CURRENT_USER
,
253 TEXT("Control Panel\\International"),
256 if (GetRegistryValue(HKEY_CLASSES_ROOT
,
257 TEXT("MIME\\Database\\Rfc1766"),
260 if(GetOemStrings(IDS_SYS_LOCALE
,Msg
)) fprintf(stderr
,Msg
,Buf
);
262 //getting Input Locale
263 if (GetRegistryValue(HKEY_CURRENT_USER
,
264 TEXT("Keyboard Layout\\Preload"),
269 for(j
= 0, i
= 4; i
<= 8; j
++, i
++) Tmp
[j
] = Buf
[i
];
270 if (GetRegistryValue(HKEY_CLASSES_ROOT
,
271 TEXT("MIME\\Database\\Rfc1766"),
274 if(GetOemStrings(IDS_INPUT_LOCALE
,Msg
)) fprintf(stderr
,Msg
,Buf
);
278 TIME_ZONE_INFORMATION TimeZoneInfo
;
279 GetTimeZoneInformation(&TimeZoneInfo
);
280 sprintf(Tmp
,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\%S",TimeZoneInfo
.StandardName
);
281 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
285 if(GetOemStrings(IDS_TIME_ZONE
,Msg
)) fprintf(stderr
,Msg
,Buf
);
287 //getting Total Physical Memory
288 GlobalMemoryStatus(&memory
);
289 if(GetOemStrings(IDS_TOTAL_PHYS_MEM
,Msg
))
292 memory
.dwTotalPhys
/(DIV
*DIV
),
293 memory
.dwTotalPhys
/DIV
);
295 //getting Available Physical Memory
296 if(GetOemStrings(IDS_AVAIL_PHISICAL_MEM
,Msg
))
299 memory
.dwAvailPhys
/(DIV
*DIV
),
300 memory
.dwAvailPhys
/DIV
);
302 //getting Virtual Memory: Max Size
303 if(GetOemStrings(IDS_VIRT_MEM_MAX
,Msg
))
306 memory
.dwTotalVirtual
/(DIV
*DIV
),
307 memory
.dwTotalVirtual
/DIV
);
309 //getting Virtual Memory: Available
310 if(GetOemStrings(IDS_VIRT_MEM_AVAIL
,Msg
))
313 memory
.dwAvailVirtual
/(DIV
*DIV
),
314 memory
.dwAvailVirtual
/DIV
);
316 //getting Virtual Memory: In Use
317 if(GetOemStrings(IDS_VIRT_MEM_INUSE
,Msg
))
320 (memory
.dwTotalVirtual
-memory
.dwAvailVirtual
)/(DIV
*DIV
),
321 (memory
.dwTotalVirtual
-memory
.dwAvailVirtual
)/DIV
);
323 //getting Page File Location(s)
324 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
325 TEXT("SYSTEM\\ControlSet001\\Control\\Session Manager\\Memory Management"),
330 for(i
= 0; i
< strlen((char*)Buf
); i
++)
338 if(GetOemStrings(IDS_PAGEFILE_LOC
,Msg
)) fprintf(stderr
,Msg
,Buf
);
342 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
343 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"),
344 TEXT("CachePrimaryDomain"),
346 if(GetOemStrings(IDS_DOMINE
,Msg
)) fprintf(stderr
,Msg
,Buf
);
348 //getting Logon Server
350 //getting NetWork Card(s)
351 if(GetOemStrings(IDS_NETWORK_CARDS
,Msg
))
359 main(int argc
,char *argv
[])
361 if (argc
> 1 && argv
[1] == "/?")