source: trunk/dll/sysinfo.c@ 793

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

Move #pragma alloc_text to end for OpenWatcom compat

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