source: trunk/dll/sysinfo.c@ 1227

Last change on this file since 1227 was 1227, checked in by John Small, 17 years ago

Ticket 187: Moved typedef's and some #define's from fm3dll.h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.7 KB
RevLine 
[47]1
2/***********************************************************************
3
4 $Id: sysinfo.c 1227 2008-09-13 23:13:11Z jbs $
5
6 System Info Display
7
8 Copyright (c) 1993-98 M. Kimes
[326]9 Copyright (c) 2002, 2006 Steven H.Levine
[47]10
[326]11 16 Oct 02 SHL Baseline
12 08 Feb 03 SHL Enable display
13 01 Aug 04 SHL RunRmview: avoid buffer overflow
[374]14 26 Jul 06 SHL Report open errors
[404]15 29 Jul 06 SHL Use xfgets
[793]16 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
[1075]17 16 JUL 08 GKY Use TMP directory for temp files
[47]18
19***********************************************************************/
20
[907]21#include <string.h>
22
[2]23#define INCL_DOS
24#define INCL_WIN
[907]25#define INCL_LONGLONG
[2]26
[1178]27#include "fm3dll.h"
[1227]28#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
29#include "sysinfo.h"
[1213]30#include "printer.h" // Data declaration(s)
31#include "init.h" // Data declaration(s)
32#include "mainwnd.h" // Data declaration(s)
[1178]33#include "fm3dlg.h"
[1073]34#include "pathutil.h" // BldFullPathName
[1178]35#include "copyf.h" // unlinkf
36#include "wrappers.h" // xfgets
37#include "systemf.h" // runemf2
38#include "misc.h" // PostMsg
39#include "strips.h" // bstrip
[2]40
41#pragma data_seg(DATA1)
[375]42
43static PSZ pszSrcFile = __FILE__;
44
[551]45VOID RunRmview(VOID * arg)
[326]46{
[551]47 HWND hwnd = (HWND) arg;
[1073]48 CHAR s[2048], *p, szTempFile[CCHMAXPATH];
[551]49 HAB thab;
50 HMQ thmq;
[2]51 FILE *fp;
[551]52 HFILE oldstdout, newstdout;
[2]53
54 DosError(FERR_DISABLEHARDERR);
55
56 thab = WinInitialize(0);
[551]57 thmq = WinCreateMsgQueue(thab, 0);
58 WinCancelShutdown(thmq, TRUE);
59 if (thab && thmq) {
60 if (!WinIsWindow(thab, hwnd))
[2]61 goto Abort;
[1075]62 BldFullPathName(szTempFile, pTmpDir, "$RMVIEW.#$#");
[1073]63 unlinkf("%s", szTempFile);
64 fp = xfopen(szTempFile, "w", pszSrcFile, __LINE__);
[374]65 if (!fp)
66 goto Abort;
67 else {
[2]68 newstdout = -1;
[551]69 if (DosDupHandle(fileno(stdout), &newstdout)) {
70 fclose(fp);
71 goto Abort;
[2]72 }
73 oldstdout = fileno(stdout);
[551]74 DosDupHandle(fileno(fp), &oldstdout);
[2]75 runemf2(SEPARATE | INVISIBLE | FULLSCREEN | BACKGROUND | WAIT,
[888]76 hwnd, pszSrcFile, __LINE__,
[1073]77 NULL, NULL, "%s", szTempFile);
[2]78 oldstdout = fileno(stdout);
[551]79 DosDupHandle(newstdout, &oldstdout);
[2]80 DosClose(newstdout);
81 fclose(fp);
82 }
[551]83 if (!WinIsWindow(thab, hwnd))
[2]84 goto Abort;
[1073]85 fp = xfopen(szTempFile, "r", pszSrcFile, __LINE__);
[374]86 if (fp) {
[551]87 xfgets(s, sizeof(s), fp, pszSrcFile, __LINE__);
88 xfgets(s, sizeof(s), fp, pszSrcFile, __LINE__);
89 if (!feof(fp) && WinIsWindow(thab, hwnd))
90 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
91 MPFROM2SHORT(LIT_END, 0),
92 MPFROMP(" -= RMView Physical Info =-"));
93 while (!feof(fp)) {
94 strset(s, 0);
95 if (!xfgets(s, sizeof(s), fp, pszSrcFile, __LINE__))
96 break;
97 stripcr(s);
98 rstrip(s);
99 p = s;
100 while (*p == '\r' || *p == '\n')
101 p++;
102 if (!WinIsWindow(thab, hwnd))
103 break;
104 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
105 MPFROM2SHORT(LIT_END, 0), MPFROMP(p));
[2]106 }
107 fclose(fp);
108 }
[551]109 Abort:
[2]110 WinDestroyMsgQueue(thmq);
111 WinTerminate(thab);
112 }
[1073]113 if (szTempFile)
114 DosForceDelete(szTempFile);
[2]115}
116
[551]117MRESULT EXPENTRY SysInfoDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[47]118{
[551]119 static HWND me = (HWND) 0;
120 static LONG ypos = 0;
121 static HPOINTER hptrIcon = (HPOINTER) 0;
[2]122
[551]123 switch (msg) {
124 case WM_INITDLG:
125 if (me) {
126 WinSetWindowPos(me, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE |
127 SWP_SHOW | SWP_RESTORE | SWP_ZORDER);
128 WinDismissDlg(hwnd, 0);
129 break;
130 }
131 hptrIcon = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, SYS_FRAME);
132 WinDefDlgProc(hwnd, WM_SETICON, MPFROMLONG(hptrIcon), MPVOID);
133 {
134 static CHAR *names[] = { "Max. Path Length", /* 1 */
135 "Max. Text Sessions", /* 2 */
136 "Max. PM Sessions", /* 3 */
137 "Max. VDM Sessions", /* 4 */
138 "Boot Drive", /* 5 */
139 "Dynamic Priority", /* 6 */
140 "Max. Wait", /* 7 */
141 "Min. Timeslice", /* 8 */
142 "Max. Timeslice", /* 9 */
143 "Page Size", /* 10 */
144 "Version Major", /* 11 */
145 "Version Minor", /* 12 */
146 "Version Revision", /* 13 */
147 "Millisecs Up", /* 14 */
148 "Unixtime Low", /* 15 */
149 "Unixtime High", /* 16 */
150 "Physical Memory", /* 17 */
151 "Resident Memory", /* 18 */
152 "Total Available Memory", /* 19 */
153 "Max. Private Memory", /* 20 */
154 "Max. Shared Memory", /* 21 */
155 "Timer Interval", /* 22 */
156 "Max. Path Comp. Length", /* 23 */
157 "Foreground FS Session ID", /* 24 */
158 "Foreground Process PID", /* 25 */
159 NULL
160 };
161 static CHAR *pnames[] = { "Swap button",
162 "Dblclk time",
163 "CX dblclk",
164 "CY dblclk",
165 "CX sizeborder",
166 "CY sizeborder",
167 "Alarm",
168 "",
169 "",
170 "Cursor rate",
171 "First scroll rate",
172 "Scroll rate",
173 "Numbered lists",
174 "Warning freq",
175 "Note freq",
176 "Error freq",
177 "Warning duration",
178 "Note duration",
179 "Error duration",
180 "",
181 "CX screen",
182 "CY screen",
183 "CX vscroll",
184 "CY hscroll",
185 "CY vscroll arrow",
186 "CX hscroll arrow",
187 "CX border",
188 "CY border",
189 "CX dlgframe",
190 "CY dlgframe",
191 "CY titlebar",
192 "CY vslider",
193 "CX hslider",
194 "CX minmaxbutton",
195 "CY minmaxbutton",
196 "CY menu",
197 "CX fullscreen",
198 "CY fullscreen",
199 "CX icon",
200 "CY icon",
201 "CX pointer",
202 "CY pointer",
203 "Debug",
204 "# Mouse buttons",
205 "Pointer level",
206 "Cursor level",
207 "Track rect level",
208 "# timers",
209 "Mouse present",
210 "CX bytealign",
211 "CY bytealign",
212 "",
213 "",
214 "",
215 "",
216 "",
217 "Not reserved",
218 "Extra key beep",
219 "Set lights",
220 "Insert mode",
221 "",
222 "",
223 "",
224 "",
225 "Menu rolldown delay",
226 "Menu rollup delay",
227 "Alt mnemonic",
228 "Tasklist mouse access",
229 "CX icon text width",
230 "# Icon text lines",
231 "Chord time",
232 "CX chord",
233 "CY chord",
234 "CX motion",
235 "CY motion",
236 "Begin drag",
237 "End drag",
238 "Single select",
239 "Open",
240 "Context menu",
241 "Context help",
242 "Text edit",
243 "Begin select",
244 "End select",
245 "Begin drag kb",
246 "End drag kb",
247 "Select kb",
248 "Open kb",
249 "Context menu kb",
250 "Context help kb",
251 "Text edit kb",
252 "Begin select kb",
253 "End select kb",
254 "Animation",
255 "Animation speed",
256 "Mono icons",
257 "Kbd id",
258 "Print screen",
259 NULL
260 };
261 static CHAR *dnames[] = { "# printers",
262 "# RS232 ports",
263 "# diskette drives",
264 "Coprocessor present",
265 "PC submodel",
266 "PC model",
267 "Display",
268 NULL
269 };
270 ULONG vals[26], val, x;
271 CHAR s[134], dev;
272
[766]273 if (DosQuerySysInfo(QSV_MAX_PATH_LENGTH, QSV_MAX_COMP_LENGTH + 2,
[551]274 (PVOID) vals, (ULONG) sizeof(vals))) {
275 WinDismissDlg(hwnd, 0);
276 break;
[2]277 }
[551]278 me = hwnd;
279 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
280 MPFROMLONG(LIT_END), MPFROMP(" -= Base OS Info =-"));
281 for (x = 0; names[x]; x++) {
282 switch (x) {
283 case 0:
284 case 9:
285 case 22:
286 sprintf(s, "%-28.28s%lu bytes", names[x], vals[x]);
287 break;
288 case 16:
289 case 17:
290 case 18:
291 case 19:
292 case 20:
293 sprintf(s, "%-28.28s%lu bytes (%lu mb)", names[x], vals[x],
294 vals[x] / (1024 * 1024));
295 break;
296 case 4:
297 sprintf(s, "%-28.28s%c:", names[x], (CHAR) vals[x] + '@');
298 break;
299 case 5:
300 sprintf(s, "%-28.28s%s", names[x], (vals[x]) ? "On" : "Off");
301 break;
302 case 6:
303 sprintf(s, "%-28.28s%lu seconds", names[x], vals[x]);
304 break;
305 case 7:
306 case 8:
307 sprintf(s, "%-28.28s%lu milliseconds", names[x], vals[x]);
308 break;
309 case 13:
310 {
311 ULONG numdays, nummins;
[2]312
[551]313 sprintf(s, "%-28.28s%lu (", names[x], vals[x]);
[766]314 vals[x] /= 60000;
315 numdays = vals[x] / (60 * 24);
[551]316 if (numdays)
317 sprintf(s + strlen(s), "%lu day%s, ", numdays,
[766]318 &"s"[numdays == 1]);
319 nummins = vals[x] % (60 * 24);
[551]320 sprintf(s + strlen(s), "%luh:%02lum)", nummins / 60,
321 nummins % 60);
322 }
323 break;
324 case 21:
325 sprintf(s, "%-28.28s%lu.%01lu milliseconds", names[x],
326 vals[x] / 10, vals[x] % 10);
327 break;
328 default:
329 sprintf(s, "%-28.28s%lu", names[x], vals[x]);
330 break;
331 }
332 if (*s)
333 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
334 MPFROMLONG(LIT_END), MPFROMP(s));
[2]335 }
[551]336 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
337 MPFROMLONG(LIT_END), MPFROMP(" -= PM Info =-"));
338 for (x = 0; pnames[x]; x++) {
339 if (*pnames[x]) {
340 val = WinQuerySysValue(HWND_DESKTOP, x);
341 switch (x) {
342 case SV_CXBYTEALIGN:
343 case SV_CYBYTEALIGN:
344 case SV_CYMOTIONSTART:
345 case SV_CXMOTIONSTART:
346 case SV_CYDBLCLK:
347 case SV_CXDBLCLK:
348 case SV_CYPOINTER:
349 case SV_CXPOINTER:
350 case SV_CYICON:
351 case SV_CXICON:
352 case SV_CXFULLSCREEN:
353 case SV_CYFULLSCREEN:
354 case SV_CYMENU:
355 case SV_CYMINMAXBUTTON:
356 case SV_CXMINMAXBUTTON:
357 case SV_CXHSLIDER:
358 case SV_CYVSLIDER:
359 case SV_CXDLGFRAME:
360 case SV_CYDLGFRAME:
361 case SV_CXSIZEBORDER:
362 case SV_CYSIZEBORDER:
363 case SV_CXBORDER:
364 case SV_CYBORDER:
365 case SV_CYTITLEBAR:
366 case SV_CXHSCROLLARROW:
367 case SV_CYVSCROLLARROW:
368 case SV_CXVSCROLL:
369 case SV_CYHSCROLL:
370 case SV_CYSCREEN:
371 case SV_CXSCREEN:
372 case SV_CXICONTEXTWIDTH:
373 case SV_CXCHORD:
374 case SV_CYCHORD:
375 sprintf(s, "%-28.28s%lu pels", pnames[x], val);
376 break;
377 case SV_CONTEXTMENU:
378 case SV_OPEN:
379 case SV_TEXTEDIT:
380 case SV_BEGINSELECT:
381 case SV_ENDSELECT:
382 case SV_BEGINDRAG:
383 case SV_ENDDRAG:
384 case SV_CONTEXTHELP:
385 case SV_SINGLESELECT:
386 sprintf(s, "%-28.28sWM: %04xh KC: %04xh", pnames[x],
387 LOUSHORT(val), HIUSHORT(val));
388 break;
389 case SV_TASKLISTMOUSEACCESS:
390 sprintf(s, "%-28.28sWM: %04xh", pnames[x], LOUSHORT(val));
391 break;
392 case SV_CONTEXTMENUKB:
393 case SV_TEXTEDITKB:
394 case SV_BEGINDRAGKB:
395 case SV_ENDDRAGKB:
396 case SV_SELECTKB:
397 case SV_OPENKB:
398 case SV_CONTEXTHELPKB:
399 case SV_BEGINSELECTKB:
400 case SV_ENDSELECTKB:
401 sprintf(s, "%-28.28sVK: %04xh KC: %04xh", pnames[x],
402 LOUSHORT(val), HIUSHORT(val));
403 break;
404 case SV_CHORDTIME:
405 case SV_DBLCLKTIME:
406 case SV_CURSORRATE:
407 case SV_FIRSTSCROLLRATE:
408 case SV_SCROLLRATE:
409 case SV_MENUROLLDOWNDELAY:
410 case SV_MENUROLLUPDELAY:
411 case SV_ANIMATIONSPEED:
412 case SV_WARNINGDURATION:
413 case SV_NOTEDURATION:
414 case SV_ERRORDURATION:
415 sprintf(s, "%-28.28s%lu milliseconds", pnames[x], val);
416 break;
417 case SV_MOUSEPRESENT:
418 sprintf(s, "%-28.28s%s", pnames[x], (val) ? "True" : "False");
419 break;
420 case SV_ALARM:
421 case SV_ANIMATION:
422 case SV_MONOICONS:
423 case SV_PRINTSCREEN:
424 case SV_SETLIGHTS:
425 case SV_INSERTMODE:
426 case SV_SWAPBUTTON:
427 case SV_DEBUG:
428 sprintf(s, "%-28.28s%s", pnames[x], (val) ? "On" : "Off");
429 break;
430 default:
431 sprintf(s, "%-28.28s%lu", pnames[x], val);
432 break;
433 }
434 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
435 MPFROMLONG(LIT_END), MPFROMP(s));
436 }
437 }
438 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
439 MPFROMLONG(LIT_END), MPFROMP(" -= Hardware info =-"));
440 for (x = 0; dnames[x]; x++) {
441 if (*dnames[x]) {
442 if (!DosDevConfig(&dev, x)) {
443 switch (x) {
444 case DEVINFO_COPROCESSOR:
445 sprintf(s, "%-28.28s%s", dnames[x], (dev) ? "True" : "False");
446 break;
447 case DEVINFO_ADAPTER:
448 sprintf(s, "%-28.28s%sMonochrome or printer", dnames[x],
449 (dev) ? "Not " : NullStr);
450 break;
451 default:
452 sprintf(s, "%-28.28s%lu", dnames[x], dev);
453 break;
454 }
455 }
456 WinSendDlgItemMsg(hwnd, SYS_LISTBOX, LM_INSERTITEM,
457 MPFROMLONG(LIT_END), MPFROMP(s));
458 }
459 }
460 }
461 break;
[2]462
[551]463 case WM_ADJUSTWINDOWPOS:
464 PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID);
465 break;
[2]466
[551]467 case UM_STRETCH:
468 {
469 SWP swpC, swp;
[2]470
[551]471 WinQueryWindowPos(hwnd, &swp);
472 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
473 WinQueryWindowPos(WinWindowFromID(hwnd, SYS_LISTBOX), &swpC);
474 if (!ypos)
475 ypos = swpC.y;
476 WinSetWindowPos(WinWindowFromID(hwnd, SYS_LISTBOX), HWND_TOP,
477 SysVal(SV_CXSIZEBORDER),
478 ypos,
479 swp.cx - (SysVal(SV_CXSIZEBORDER) * 2),
480 (swp.cy - ypos) - (SysVal(SV_CYTITLEBAR) +
481 SysVal(SV_CYSIZEBORDER)),
482 SWP_MOVE | SWP_SIZE);
[2]483 }
[551]484 }
485 return 0;
[2]486
[551]487 case WM_COMMAND:
488 WinDismissDlg(hwnd, 0);
489 return 0;
[2]490
[551]491 case WM_DESTROY:
492 if (me == hwnd) {
493 me = (HWND) 0;
494 if (hptrIcon)
495 WinDestroyPointer(hptrIcon);
496 hptrIcon = (HPOINTER) 0;
497 }
498 break;
[2]499 }
500
[551]501 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]502}
[793]503
504#pragma alloc_text(SYSINFO,SysInfoDlgProc,RunRmview)
Note: See TracBrowser for help on using the repository browser.