source: trunk/dll/sysinfo.c@ 1073

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

Fm2 uses TMP/TEMP directory if set for temporary files and directories. Ticket 20

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