source: trunk/dll/sysinfo.c@ 888

Last change on this file since 888 was 888, checked in by Gregg Young, 18 years ago

runemf2 now quotes executable strings if needed (Ticket 180); it also reports where it was called from on errors

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