source: trunk/dll/sysinfo.c@ 1544

Last change on this file since 1544 was 1544, checked in by Gregg Young, 15 years ago

Changes to fopen and _fsopen to allow FM2 to be loaded in high memory

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