source: trunk/dll/sysinfo.c@ 1156

Last change on this file since 1156 was 1156, checked in by John Small, 17 years ago

Ticket 187: Draft 1: Functions only

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