source: trunk/dll/sysinfo.c@ 1036

Last change on this file since 1036 was 907, checked in by Steven Levine, 18 years ago

Avoid out of memory traps in Compare Directories
Rework Compare Directories progress display for 2 second update rate
Start refactoring to reduce dependence on fm3dll.h
Add timer services (IsITimerExpired etc.)

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