source: trunk/dll/sysinfo.c@ 1075

Last change on this file since 1075 was 1075, checked in by Gregg Young, 17 years ago

Debulked TMP code; Added comments;

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