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;
89 TIME_ZONE_INFORMATION TimeZoneInfo
;
91 GetSystemInfo(&SysInfo
);
93 // getting computer name
94 CharCount
= BUFFER_SIZE
;
95 if(!GetComputerName(Buf
,&CharCount
)) printf("Error getting: GetComputerName");
96 if(GetOemStrings(IDS_HOST_NAME
,Msg
)) fprintf(stderr
,Msg
,Buf
);
99 GetRegistryValue(HKEY_LOCAL_MACHINE
,
100 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
103 if(GetOemStrings(IDS_OS_NAME
,Msg
)) fprintf(stderr
,Msg
,Buf
);
106 ZeroMemory(&VersionInfo
, sizeof(OSVERSIONINFO
));
107 VersionInfo
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
108 if(!(bOsVersionInfoEx
= GetVersionEx((OSVERSIONINFO
*)&VersionInfo
)))
110 VersionInfo
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
111 if (!GetVersionEx((OSVERSIONINFO
*)&VersionInfo
))
114 if (VersionInfo
.dwPlatformId
== VER_PLATFORM_WIN32_NT
)
116 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
117 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
120 if(GetOemStrings(IDS_OS_VERSION
,Msg
))
122 (int)VersionInfo
.dwMajorVersion
,
123 (int)VersionInfo
.dwMinorVersion
,
124 (int)VersionInfo
.dwBuildNumber
,
126 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
127 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
128 TEXT("CurrentBuildNumber"),
130 if(GetOemStrings(IDS_OS_BUILD
,Msg
)) fprintf(stderr
,Msg
,Buf
);
133 //getting OS Manufacturer
135 //getting OS Configuration
137 //getting OS Build Type
138 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
139 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
142 if(GetOemStrings(IDS_OS_BUILD_TYPE
,Msg
)) fprintf(stderr
,Msg
,Buf
);
144 //getting Registered Owner
145 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
146 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
147 TEXT("RegisteredOwner"),
149 if(GetOemStrings(IDS_REG_OWNER
,Msg
)) fprintf(stderr
,Msg
,Buf
);
151 //getting Registered Organization
152 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
153 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
154 TEXT("RegisteredOrganization"),
156 if(GetOemStrings(IDS_REG_ORG
,Msg
)) fprintf(stderr
,Msg
,Buf
);
159 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
160 TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"),
163 if(GetOemStrings(IDS_PRODUCT_ID
,Msg
)) fprintf(stderr
,Msg
,Buf
);
165 //getting Install Date
166 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
167 TEXT("SOFTWARE\\Microsoft\\WBEM\\CIMOM"),
170 if(GetOemStrings(IDS_INST_DATE
,Msg
)) fprintf(stderr
,Msg
,Buf
);
172 //getting Install Time
173 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
174 TEXT("SOFTWARE\\Microsoft\\WBEM\\CIMOM"),
177 if(GetOemStrings(IDS_INST_TIME
,Msg
)) fprintf(stderr
,Msg
,Buf
);
179 //getting System Up Time
181 //getting System Manufacturer
183 //getting System Model
185 //getting System type
186 switch (SysInfo
.wProcessorArchitecture
)
188 case PROCESSOR_ARCHITECTURE_UNKNOWN
:
189 if(GetOemStrings(IDS_SYS_TYPE_UNKNOWN
,Msg
)) printf("%s",Msg
);
191 case PROCESSOR_ARCHITECTURE_INTEL
:
192 if(GetOemStrings(IDS_SYS_TYPE_X86
,Msg
)) printf("%s",Msg
);
194 case PROCESSOR_ARCHITECTURE_IA64
:
195 if(GetOemStrings(IDS_SYS_TYPE_IA64
,Msg
)) printf("%s",Msg
);
197 case PROCESSOR_ARCHITECTURE_AMD64
:
198 if(GetOemStrings(IDS_SYS_TYPE_AMD64
,Msg
)) printf("%s",Msg
);
202 //getting Processor(s)
203 if(GetOemStrings(IDS_PROCESSORS
,Msg
))
206 fprintf(stderr
,Msg
,(unsigned int)SysInfo
.dwNumberOfProcessors
);
207 for(i
= 0; i
< (unsigned int)SysInfo
.dwNumberOfProcessors
; i
++)
209 sprintf(Tmp
,"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%u",i
);
210 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
214 printf(" [0%u]: %s",i
+1,Buf
);
215 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
217 TEXT("VendorIdentifier"),
223 //getting BIOS Version
224 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
225 TEXT("HARDWARE\\DESCRIPTION\\System"),
226 TEXT("SystemBiosVersion"),
228 if(GetOemStrings(IDS_BIOS_VERSION
,Msg
)) fprintf(stderr
,Msg
,Buf
);
231 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
232 TEXT("HARDWARE\\DESCRIPTION\\System"),
233 TEXT("SystemBiosDate"),
235 if(GetOemStrings(IDS_BIOS_DATE
,Msg
)) fprintf(stderr
,Msg
,Buf
);
237 //getting ReactOS Directory
238 if(!GetWindowsDirectory(Buf
,BUFFER_SIZE
)) printf("Error getting: GetWindowsDirectory");
239 if(GetOemStrings(IDS_ROS_DIR
,Msg
)) fprintf(stderr
,Msg
,Buf
);
241 //getting System Directory
242 if(!GetSystemDirectory(Buf
,BUFFER_SIZE
)) printf("Error getting: GetSystemDirectory");
243 if(GetOemStrings(IDS_SYS_DIR
,Msg
)) fprintf(stderr
,Msg
,Buf
);
245 //getting Boot Device
246 if (GetRegistryValue(HKEY_LOCAL_MACHINE
,
247 TEXT("SYSTEM\\Setup"),
248 TEXT("SystemPartition"),
250 if(GetOemStrings(IDS_BOOT_DEV
,Msg
)) fprintf(stderr
,Msg
,Buf
);
252 //getting System Locale
253 if (GetRegistryValue(HKEY_CURRENT_USER
,
254 TEXT("Control Panel\\International"),
257 if (GetRegistryValue(HKEY_CLASSES_ROOT
,
258 TEXT("MIME\\Database\\Rfc1766"),
261 if(GetOemStrings(IDS_SYS_LOCALE
,Msg
)) fprintf(stderr
,Msg
,Buf
);
263 //getting Input Locale
264 if (GetRegistryValue(HKEY_CURRENT_USER
,
265 TEXT("Keyboard Layout\\Preload"),
270 for(j
= 0, i
= 4; i
<= 8; j
++, i
++) Tmp
[j
] = Buf
[i
];
271 if (GetRegistryValue(HKEY_CLASSES_ROOT
,
272 TEXT("MIME\\Database\\Rfc1766"),
275 if(GetOemStrings(IDS_INPUT_LOCALE
,Msg
)) fprintf(stderr
,Msg
,Buf
);
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 && !strcmp(argv
[1], "/?"))