source: trunk/dll/sysinfo.c@ 1213

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

Ticket 187: Move data declarations/definitions out of fm3dll.h

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