source: trunk/dll/sysinfo.c@ 1402

Last change on this file since 1402 was 1402, checked in by Gregg Young, 16 years ago

Remove variable aurgs from docopy & unlinkf (not used); Move more strings to PCSZs and string table; Move PCSZs to compile time initialization; Fix hang on startup caused by a drive scan and a dircnr scan trying to update a drive in the tree at the same time (related to the "treeswitch options); Code cleanup mainly removal of old printfs, SayMsgs, DbgMsg and unneeded %s.

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