source: trunk/dll/init.c@ 689

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

Commit OpenWatcom compatibility updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 39.1 KB
Line 
1
2/***********************************************************************
3
4 $Id: init.c 689 2007-06-15 06:33:24Z stevenhl $
5
6 Initialization
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2001, 2007 Steven H. Levine
10
11 11 Jun 02 SHL Add CheckVersion
12 11 Jun 03 SHL Add JFS and FAT32 support
13 25 Nov 03 SHL InitFM3DLL: correct strings error mesage
14 23 May 05 SHL Use datamin.h
15 26 May 05 SHL Comments
16 06 Jun 05 SHL indent -i2
17 06 Jun 05 SHL Rework FindSwapperDat for VAC3.65 compat
18 13 Jul 06 SHL Use Runtime_Error
19 13 Jul 06 SHL Sync with current style
20 29 Jul 06 SHL Use xfgets
21 22 Oct 06 GKY Add NDFS32 support
22 18 Feb 07 GKY Add ISOFS, RAMFS support
23 30 Mar 07 GKY Defined golbals for removing GetPString for window class names
24 21 Apr 07 GKY Find FM2Utils by path or utils directory eleminate fAddUtils global
25
26***********************************************************************/
27
28#define DEFINE_GLOBALS 1
29
30#define INCL_DOS
31#define INCL_WIN
32#define INCL_MMIOOS2
33#define INCL_GPI
34
35#include <os2.h>
36#include <os2me.h>
37#include <stdlib.h>
38#include <stdio.h>
39#include <string.h>
40#include <ctype.h>
41#include <share.h>
42#include <time.h>
43#include <process.h>
44
45#include "fm3dll.h"
46#include "fm3dlg.h"
47#include "datamin.h"
48#include "tools.h"
49#include "fm3str.h"
50#include "version.h"
51
52#pragma alloc_text(INIT,_DLL_InitTerm,InitFM3DLL,DeInitFM3DLL)
53#pragma alloc_text(INIT1,StartFM3,FindSwapperDat)
54
55extern int _CRT_init(void);
56extern void _CRT_term(void);
57
58static PSZ pszSrcFile = __FILE__;
59
60VOID FindSwapperDat(VOID)
61{
62 CHAR filename[] = "C:\\CONFIG.SYS";
63 CHAR input[8192];
64 CHAR *p;
65 CHAR *pp;
66 FILE *fp;
67 FILEFINDBUF3 ffb;
68 ULONG nm;
69 ULONG size = sizeof(SwapperDat);
70 HDIR hdir = HDIR_CREATE;
71 APIRET rc = 1;
72
73 *SwapperDat = 0;
74 // Check already known
75 PrfQueryProfileData(fmprof,
76 FM3Str, "SwapperDat", (PVOID) SwapperDat, &size);
77 if (*SwapperDat) {
78 nm = 1;
79 rc = DosFindFirst(SwapperDat,
80 &hdir,
81 FILE_NORMAL | FILE_ARCHIVED |
82 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
83 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
84 if (!rc) {
85 DosFindClose(hdir);
86 fp = fopen(SwapperDat, "r");
87 if (fp) {
88 fclose(fp);
89 *SwapperDat = 0;
90 rc = 1; // Force config.sys scan
91 }
92 }
93 else
94 *SwapperDat = 0;
95 }
96 // If not defined in INI or INI wrong, scan config.sys for SWAPPATH statement
97 if (rc) {
98 if (DosQuerySysInfo(QSV_BOOT_DRIVE,
99 QSV_BOOT_DRIVE,
100 (PVOID) & nm, (ULONG) sizeof(ULONG))) {
101 nm = 3; // Assume drive C:
102 }
103 *filename = (CHAR) nm + '@';
104 fp = xfsopen(filename, "r", SH_DENYNO, pszSrcFile, __LINE__);
105 if (fp) {
106 while (!feof(fp)) {
107 if (!xfgets(input, sizeof(input), fp, pszSrcFile, __LINE__))
108 break;
109 lstrip(input);
110 if (!strnicmp(input, "SWAPPATH", 8)) {
111 p = input + 8;
112 while (*p == ' ')
113 p++;
114 if (*p == '=') {
115 p++;
116 stripcr(p);
117 rstrip(p);
118 while (*p == ' ')
119 p++;
120 if (*p == '\"') {
121 p++;
122 pp = p;
123 while (*pp && *pp != '\"')
124 *pp += 1;
125 if (*pp)
126 *pp = 0;
127 }
128 else {
129 pp = strchr(p, ' ');
130 if (pp)
131 *pp = 0;
132 }
133 if (*p) {
134 strncpy(SwapperDat, p, CCHMAXPATH);
135 SwapperDat[CCHMAXPATH - 1] = 0;
136 if (SwapperDat[strlen(SwapperDat) - 1] != '\\')
137 strcat(SwapperDat, "\\");
138 strcat(SwapperDat, "SWAPPER.DAT");
139 hdir = HDIR_CREATE;
140 nm = 1;
141 if (!DosFindFirst(SwapperDat,
142 &hdir,
143 FILE_NORMAL | FILE_ARCHIVED |
144 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
145 &ffb, sizeof(ffb), &nm, FIL_STANDARD)) {
146 DosFindClose(hdir);
147 PrfWriteProfileString(fmprof,
148 FM3Str, "SwapperDat", SwapperDat);
149 }
150 else
151 *SwapperDat = 0;
152 break;
153 }
154 }
155 } // if SWAPPATH
156 } // while
157 fclose(fp);
158 }
159 }
160}
161
162unsigned long _System _DLL_InitTerm(unsigned long hModule,
163 unsigned long ulFlag)
164{
165 CHAR *env;
166 CHAR stringfile[CCHMAXPATH];
167 FILESTATUS3 fsa;
168 APIRET rc;
169
170 switch (ulFlag) {
171 case 0:
172 if (_CRT_init() == -1)
173 return 0UL;
174 FM3DllHandle = hModule;
175 strcpy(stringfile, "FM3RES.STR");
176 env = getenv("FM3INI");
177 if (env) {
178 DosError(FERR_DISABLEHARDERR);
179 rc = DosQueryPathInfo(env, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
180 if (!rc) {
181 if (fsa.attrFile & FILE_DIRECTORY) {
182 strcpy(stringfile, env);
183 if (stringfile[strlen(stringfile) - 1] != '\\')
184 strcat(stringfile, "\\");
185 strcat(stringfile, "FM3RES.STR");
186 DosError(FERR_DISABLEHARDERR);
187 if (DosQueryPathInfo(stringfile, FIL_STANDARD, &fsa, sizeof(fsa)))
188 strcpy(stringfile, "FM3RES.STR");
189 }
190 }
191 }
192 LoadStrings(stringfile);
193
194 DosError(FERR_DISABLEHARDERR);
195 /* strings here to prevent multiple occurences in DLL */
196 FM2Str = "FM/2";
197 FM3Str = "FM/3";
198 NullStr = "";
199 Default = "DEFAULT";
200 Settings = "SETTINGS";
201 WPProgram = "WPProgram";
202 FM3Folder = "<FM3_Folder>";
203 FM3Tools = "<FM3_Tools>";
204 DRM_OS2FILE = "DRM_OS2FILE";
205 DRM_FM2ARCMEMBER = "DRM_FM2ARCMEMBER";
206 DRF_FM2ARCHIVE = "DRF_FM2ARCHIVE";
207 DRMDRFLIST = "<DRM_OS2FILE,DRF_UNKNOWN>,"
208 "<DRM_DISCARD,DRF_UNKNOWN>," "<DRM_PRINT,DRF_UNKNOWN>";
209 DRMDRFOS2FILE = "<DRM_OS2FILE,DRF_UNKNOWN>";
210 DRMDRFFM2ARC = "<DRM_FM2ARCMEMBER,DRF_FM2ARCHIVE>";
211 DRM_FM2INIRECORD = "DRM_FM2INIRECORD";
212 DRF_FM2INI = "DRF_FM2INI";
213 SUBJECT = ".SUBJECT";
214 LONGNAME = ".LONGNAME";
215 HPFS = "HPFS";
216 JFS = "JFS";
217 CDFS = "CDFS";
218 ISOFS = "ISOFS";
219 FAT32 = "FAT32";
220 HPFS386 = "HPFS386";
221 CBSIFS = "CBSIFS";
222 NDFS32 = "NDFS32";
223 RAMFS = "RAMFS";
224 NTFS = "NTFS";
225 WC_OBJECTWINDOW = "WC_OBJECTWINDOW";
226 WC_BUBBLE = "WC_BUBBLE";
227 WC_TOOLBUTTONS = "WC_TOOLBUTTONS";
228 WC_DRIVEBUTTONS = "WC_DRIVEBUTTONS";
229 WC_DIRCONTAINER = "WC_DIRCONTAINER";
230 WC_DIRSTATUS = "WC_DIRSTATUS";
231 WC_TREECONTAINER = "WC_TREECONTAINER";
232 WC_TREEOPENBUTTON = "WC_TREEOPENBUTTON";
233 WC_TREESTATUS = "WC_TREESTATUS";
234 WC_MAINWND = "WC_MAINWND";
235 WC_MAINWND2 = "WC_MAINWND2";
236 WC_AUTOVIEW = "WC_AUTOVIEW";
237 WC_LED = "WC_LED";
238 WC_COLLECTOR = "WC_COLLECTOR";
239 WC_COLSTATUS = "WC_COLSTATUS";
240 WC_STATUS = "WC_STATUS";
241 WC_TOOLBACK = "WC_TOOLBACK";
242 WC_DRIVEBACK = "WC_DRIVEBACK";
243 WC_ARCCONTAINER = "WC_ARCCONTAINER";
244 WC_ARCSTATUS = "WC_ARCSTATUS";
245 WC_MLEEDITOR = "WC_MLEEDITOR";
246 WC_INIEDITOR = "WC_INIEDITOR";
247 WC_SEEALL = "WC_SEEALL";
248 WC_NEWVIEW = "WC_NEWVIEW";
249 WC_SEESTATUS = "WC_SEESTATUS";
250 WC_VIEWSTATUS = "WC_VIEWSTATUS";
251 WC_ERRORWND = "WC_ERRORWND";
252 WC_MINITIME = "WC_MINITIME";
253 WC_DATABAR = "WC_DATABAR";
254
255 /* end of strings */
256 memset(&RGBBLACK, 0, sizeof(RGB2));
257 RGBGREY.bRed = RGBGREY.bGreen = RGBGREY.bBlue = (BYTE)204;
258 RGBGREY.fcOptions = 0;
259 FM3UL = *(ULONG *) FM3Str;
260 DEBUG_STRING = "Debug -- please report to author";
261 break;
262 case 1:
263 StopPrinting = 1;
264 if (fmprof)
265 PrfCloseProfile(fmprof);
266 DosError(FERR_ENABLEHARDERR);
267 _CRT_term();
268 break;
269 default:
270 return 0UL;
271 }
272 return 1UL;
273}
274
275VOID APIENTRY DeInitFM3DLL(ULONG why)
276{
277 /* cleanup */
278 static CHAR s[CCHMAXPATH];
279 CHAR *enddir;
280 HDIR search_handle;
281 ULONG num_matches;
282 static FILEFINDBUF3 f;
283
284 StopTimer();
285 StopPrinting = 1;
286
287 if (LogFileHandle)
288 fclose(LogFileHandle);
289
290 if (fmprof) {
291 PrfCloseProfile(fmprof);
292 fmprof = (HINI) 0;
293 if (fIniExisted) {
294 DosError(FERR_DISABLEHARDERR);
295 DosCopy("FM3.INI", "FM3INI.BAK", DCPY_EXISTING);
296 }
297 }
298
299 if (fToolsChanged)
300 save_tools(NULL);
301
302# ifdef __IBMC__
303 _fcloseall();
304# else // __WATCOMC__
305 fcloseall();
306# endif
307
308 save_dir(s);
309 if (s[strlen(s) - 1] != '\\')
310 strcat(s, "\\");
311 enddir = &s[strlen(s)];
312 if (*ArcTempRoot) {
313 strcat(s, ArcTempRoot);
314 strcat(s, "*");
315 search_handle = HDIR_CREATE;
316 num_matches = 1L;
317 if (!DosFindFirst(s,
318 &search_handle,
319 FILE_NORMAL | FILE_DIRECTORY |
320 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
321 FILE_ARCHIVED,
322 &f, sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
323 do {
324 strcpy(enddir, f.achName);
325 if (f.attrFile & FILE_DIRECTORY) {
326 wipeallf("%s\\*", s);
327 DosDeleteDir(s);
328 }
329 else
330 unlinkf("%s", s);
331 }
332 while (!DosFindNext(search_handle,
333 &f, sizeof(FILEFINDBUF3), &num_matches));
334 DosFindClose(search_handle);
335 }
336 }
337
338 save_dir(s);
339 if (s[strlen(s) - 1] != '\\')
340 strcat(s, "\\");
341 enddir = &s[strlen(s)];
342 strcat(s, LISTTEMPROOT);
343 strcat(s, "???");
344 search_handle = HDIR_CREATE;
345 num_matches = 1L;
346 if (!DosFindFirst(s,
347 &search_handle,
348 FILE_NORMAL | FILE_DIRECTORY |
349 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
350 FILE_ARCHIVED,
351 &f, sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
352 do {
353 if (!(f.attrFile & FILE_DIRECTORY)) {
354 strcpy(enddir, f.achName);
355 unlinkf("%s", s);
356 }
357 }
358 while (!DosFindNext(search_handle,
359 &f, sizeof(FILEFINDBUF3), &num_matches));
360 DosFindClose(search_handle);
361 }
362
363 DosForceDelete("$FM2PLAY.$$$");
364
365 EndNote();
366
367 if (FM3ModHandle)
368 DosFreeModule(FM3ModHandle);
369
370 DosExitList(EXLST_REMOVE, DeInitFM3DLL);
371}
372
373BOOL InitFM3DLL(HAB hab, int argc, char **argv)
374{
375 /*
376 * this function should be called by any application using this DLL right
377 * after setting up a message queue
378 */
379
380 CLASSINFO clinfo;
381 APIRET rc;
382 APIRET rcl = 1;
383 APIRET rcq = 1;
384 PFN pfnResVersion = (PFN) NULL;
385 ULONG RVMajor = 0;
386 ULONG RVMinor = 0;
387 ULONG ret = 0;
388 FILESTATUS3 fsa;
389 CHAR *env;
390 CHAR dllfile[CCHMAXPATH];
391 ULONG size;
392
393 if (!StringsLoaded()) {
394 saymsg(MB_ENTER,
395 HWND_DESKTOP,
396 "Error",
397 "FM3RES.STR isn't in right format, at least "
398 "for this version of FM/2.");
399 return FALSE;
400 }
401
402 strcpy(dllfile, "FM3RES");
403 env = getenv("FM3INI");
404 if (env) {
405 FILESTATUS3 fsa;
406 APIRET rc;
407
408 DosError(FERR_DISABLEHARDERR);
409 rc = DosQueryPathInfo(env, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
410 if (!rc) {
411 if (fsa.attrFile & FILE_DIRECTORY) {
412 strcpy(dllfile, env);
413 if (dllfile[strlen(dllfile) - 1] != '\\')
414 strcat(dllfile, "\\");
415 strcat(dllfile, "FM3RES");
416 DosError(FERR_DISABLEHARDERR);
417 if (DosQueryPathInfo(dllfile, FIL_STANDARD, &fsa, sizeof(fsa)))
418 strcpy(dllfile, "FM3RES");
419 }
420 }
421 }
422 rcl = DosLoadModule(NULL, 0, dllfile, &FM3ModHandle);
423 if (rcl) {
424 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
425 HWND_DESKTOP,
426 GetPString(IDS_ERRORTEXT), GetPString(IDS_FM3RESERROR1TEXT));
427 return FALSE;
428 }
429 else {
430 rc = DosExitList(EXLST_ADD, DeInitFM3DLL);
431 if (rc) {
432 Dos_Error(MB_ENTER,
433 rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosExitList failed");
434 }
435 rcq = DosQueryProcAddr(FM3ModHandle, 1, "ResVersion", &pfnResVersion);
436 if (!rcq)
437 ret = pfnResVersion(&RVMajor, &RVMinor);
438 }
439
440 if (RVMajor < VERMAJOR || (RVMajor == VERMAJOR && RVMinor < VERMINOR)) {
441 saymsg(MB_ENTER,
442 HWND_DESKTOP,
443 GetPString(IDS_ERRORTEXT),
444 GetPString(IDS_FM3RESERROR2TEXT),
445 !rcq ?
446 GetPString(IDS_FM3RESERROR3TEXT) :
447 !rcl ?
448 GetPString(IDS_FM3RESERROR4TEXT) :
449 GetPString(IDS_FM3RESERROR5TEXT), RVMajor, RVMinor, rcl, rcq, ret);
450 return FALSE;
451 }
452
453 ArgDriveFlags(argc, argv);
454 FillInDriveFlags(NULL);
455
456 if (!*profile)
457 strcpy(profile, "FM3.INI");
458 mypid = getpid();
459 /* give default appname if none set by caller */
460 if (!*appname)
461 strcpy(appname, FM3Str);
462 /* save appname; may be reset below */
463 strcpy(realappname, appname);
464 if (!strcmp(appname, FM3Str))
465 DosSetMaxFH(100L);
466 else if (!strcmp(appname, "VDir") ||
467 !strcmp(appname, "VTree") ||
468 !strcmp(appname, "VCollect") ||
469 !strcmp(appname, "SEEALL") || !strcmp(appname, "FM/4"))
470 DosSetMaxFH(60L);
471 else
472 DosSetMaxFH(40L);
473
474 if (DosQuerySysInfo(QSV_VERSION_MAJOR,
475 QSV_VERSION_MINOR,
476 (PVOID) OS2ver, (ULONG) sizeof(OS2ver))) {
477 OS2ver[0] = 2;
478 OS2ver[1] = 1;
479 }
480
481 /* set up default root names for temp archive goodies */
482 if (!fAmAV2)
483 strcpy(ArcTempRoot, "$FM$ARC$");
484 else
485 strcpy(ArcTempRoot, "$AV$ARC$");
486
487 /* initialize random number generator */
488 srand(time(NULL) + clock());
489
490 priority_bumped();
491
492 /* _heapmin() is done in a separate thread -- start it */
493 if (_beginthread(HeapThread, NULL, 32768, NULL) == -1) {
494 Runtime_Error(pszSrcFile, __LINE__,
495 GetPString(IDS_COULDNTSTARTTHREADTEXT));
496 return FALSE;
497 }
498 /* timer messages are sent from a separate thread -- start it */
499 if (!StartTimer())
500 return FALSE;
501
502 /* are we the workplace shell? */
503 env = getenv("WORKPLACE__PROCESS");
504 if (!env || stricmp(env, "NO"))
505 fWorkPlace = TRUE;
506
507 if ((!strchr(profile, '\\') && !strchr(profile, ':')) ||
508 !(fmprof = PrfOpenProfile((HAB) 0, profile))) {
509 /* figure out where to put INI file... */
510 CHAR *env, inipath[CCHMAXPATH];
511
512 DosError(FERR_DISABLEHARDERR);
513 save_dir2(HomePath);
514 DosError(FERR_DISABLEHARDERR);
515 memset(driveserial, -1, sizeof(driveserial));
516 *inipath = 0;
517 env = getenv("FM3INI");
518 if (env) {
519 strcpy(inipath, env);
520 DosError(FERR_DISABLEHARDERR);
521 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
522 if (!rc) {
523 if (fsa.attrFile & FILE_DIRECTORY) {
524 if (inipath[strlen(inipath) - 1] != '\\')
525 strcat(inipath, "\\");
526 strcat(inipath, profile);
527 }
528 }
529 }
530 if (!env) {
531 env = searchpath(profile);
532 if (!env)
533 env = profile;
534 strcpy(inipath, env);
535 }
536
537 /* in some odd cases the INI file can get set to readonly status */
538 /* here we test it and reset the readonly bit if necessary */
539 if (!*inipath)
540 strcpy(inipath, profile);
541 DosError(FERR_DISABLEHARDERR);
542 if (!DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa))) {
543 fIniExisted = TRUE;
544 if (fsa.attrFile & (FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM)) {
545 fsa.attrFile &= (~(FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM));
546 if (DosSetPathInfo(inipath, FIL_STANDARD, (PVOID) & fsa,
547 (ULONG) sizeof(fsa), 0L))
548 saymsg(MB_ENTER,
549 HWND_DESKTOP,
550 GetPString(IDS_ERRORTEXT),
551 GetPString(IDS_INIREADONLYTEXT), inipath);
552 }
553 }
554
555 fmprof = PrfOpenProfile((HAB) 0, inipath);
556 if (!fmprof) {
557 strcpy(inipath, "FM3.INI");
558 fmprof = PrfOpenProfile((HAB) 0, inipath);
559 }
560
561 if (!fmprof) {
562 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
563 "PrfOpenProfile failed");
564 return FALSE;
565 }
566 }
567
568 FindSwapperDat();
569
570 size = sizeof(BOOL);
571 PrfQueryProfileData(fmprof,
572 FM3Str,
573 "SeparateParms", (PVOID) & fSeparateParms, &size);
574 if (!fSeparateParms)
575 strcpy(appname, FM3Str);
576
577 /* start help */
578 memset(&hini, 0, sizeof(HELPINIT));
579 hini.cb = sizeof(HELPINIT);
580 hini.ulReturnCode = 0L;
581 hini.pszTutorialName = NULL;
582 hini.phtHelpTable = (PHELPTABLE) MAKELONG(ID_HELPTABLE, 0xffff);
583 hini.hmodAccelActionBarModule = (HMODULE) 0;
584 hini.idAccelTable = 0;
585 hini.idActionBar = 0;
586 hini.pszHelpWindowTitle = GetPString(IDS_FM2HELPTITLETEXT);
587 hini.fShowPanelId = CMIC_HIDE_PANEL_ID;
588 hini.pszHelpLibraryName = "FM3.HLP";
589 hwndHelp = WinCreateHelpInstance(hab, &hini);
590 if (!hwndHelp) {
591 static CHAR helppath[CCHMAXPATH]; // fixme to be local?
592
593 env = getenv("FM3INI");
594 if (env) {
595 FILESTATUS3 fsa;
596 APIRET rc;
597
598 strcpy(helppath, env);
599 DosError(FERR_DISABLEHARDERR);
600 rc =
601 DosQueryPathInfo(helppath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
602 if (!rc) {
603 if (fsa.attrFile & FILE_DIRECTORY) {
604 if (helppath[strlen(helppath) - 1] != '\\')
605 strcat(helppath, "\\");
606 strcat(helppath, "FM3.HLP");
607 hini.pszHelpLibraryName = helppath;
608 hwndHelp = WinCreateHelpInstance(hab, &hini);
609 }
610 }
611 }
612 }
613 if (!hwndHelp) {
614 saymsg(MB_ENTER | MB_ICONEXCLAMATION,
615 HWND_DESKTOP,
616 GetPString(IDS_FM2TROUBLETEXT),
617 GetPString(IDS_CANTLOADHELPTEXT),
618 GetPString(IDS_NOHELPACCEPTTEXT));
619 }
620
621 /* a couple of default window procs so we don't have to look them up later */
622 if (WinQueryClassInfo(hab, WC_CONTAINER, &clinfo))
623 PFNWPCnr = clinfo.pfnWindowProc;
624 // saymsg(MB_ENTER,HWND_DESKTOP,"Container flags:","%08lx",clinfo.flClassStyle);
625 if (WinQueryClassInfo(hab, WC_FRAME, &clinfo))
626 PFNWPFrame = clinfo.pfnWindowProc;
627 // saymsg(MB_ENTER,HWND_DESKTOP,"Frame flags:","%08lx",clinfo.flClassStyle);
628 if (WinQueryClassInfo(hab, WC_BUTTON, &clinfo))
629 PFNWPButton = clinfo.pfnWindowProc;
630 // saymsg(MB_ENTER,HWND_DESKTOP,"Button flags:","%08lx",clinfo.flClassStyle);
631 if (WinQueryClassInfo(hab, WC_STATIC, &clinfo))
632 PFNWPStatic = clinfo.pfnWindowProc;
633 // saymsg(MB_ENTER,HWND_DESKTOP,"Static flags:","%08lx",clinfo.flClassStyle);
634 if (WinQueryClassInfo(hab, WC_MLE, &clinfo))
635 PFNWPMLE = clinfo.pfnWindowProc;
636 // saymsg(MB_ENTER,HWND_DESKTOP,"MLE flags:","%08lx",clinfo.flClassStyle);
637 if (!PFNWPCnr || !PFNWPFrame || !PFNWPButton || !PFNWPStatic || !PFNWPMLE) {
638 Runtime_Error(pszSrcFile, __LINE__, "WinQueryClassInfo");
639 return FALSE;
640 }
641
642 /* register window classes we use */
643 WinRegisterClass(hab,
644 WC_MAINWND,
645 MainWndProc,
646 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 8);
647 WinRegisterClass(hab,
648 WC_MAINWND2,
649 MainWndProc2,
650 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 4);
651 WinRegisterClass(hab,
652 WC_TREECONTAINER,
653 TreeClientWndProc,
654 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
655 WinRegisterClass(hab,
656 WC_DIRCONTAINER,
657 DirClientWndProc,
658 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
659 WinRegisterClass(hab,
660 WC_COLLECTOR,
661 CollectorClientWndProc,
662 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
663 WinRegisterClass(hab,
664 WC_ARCCONTAINER,
665 ArcClientWndProc,
666 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
667 WinRegisterClass(hab,
668 WC_MLEEDITOR,
669 MLEEditorProc,
670 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
671 WinRegisterClass(hab,
672 WC_INIEDITOR,
673 IniProc,
674 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
675 WinRegisterClass(hab,
676 WC_TOOLBACK,
677 ToolBackProc, CS_SIZEREDRAW, sizeof(PVOID));
678 WinRegisterClass(hab,
679 WC_DRIVEBACK,
680 DriveBackProc,
681 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
682 sizeof(PVOID));
683 WinRegisterClass(hab,
684 WC_SEEALL,
685 SeeAllWndProc,
686 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
687 WinRegisterClass(hab,
688 WC_NEWVIEW,
689 ViewWndProc,
690 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
691 WinRegisterClass(hab,
692 WC_TOOLBUTTONS,
693 ChildButtonProc,
694 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
695 sizeof(PVOID));
696 WinRegisterClass(hab,
697 WC_DRIVEBUTTONS,
698 DriveProc,
699 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
700 sizeof(PVOID));
701 WinRegisterClass(hab,
702 WC_BUBBLE,
703 BubbleProc,
704 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
705 sizeof(ULONG) * 2);
706 WinRegisterClass(hab,
707 WC_STATUS,
708 StatusProc,
709 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
710 sizeof(ULONG));
711 WinRegisterClass(hab,
712 WC_DIRSTATUS,
713 DirTextProc,
714 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
715 sizeof(ULONG));
716 WinRegisterClass(hab,
717 WC_TREESTATUS,
718 TreeStatProc,
719 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
720 sizeof(ULONG));
721 WinRegisterClass(hab,
722 WC_ARCSTATUS,
723 ArcTextProc,
724 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
725 sizeof(ULONG));
726 WinRegisterClass(hab,
727 WC_COLSTATUS,
728 CollectorTextProc,
729 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
730 sizeof(ULONG));
731 WinRegisterClass(hab,
732 WC_SEESTATUS,
733 SeeStatusProc,
734 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
735 sizeof(ULONG));
736 WinRegisterClass(hab,
737 WC_VIEWSTATUS,
738 ViewStatusProc,
739 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
740 sizeof(ULONG));
741 WinRegisterClass(hab,
742 WC_ERRORWND,
743 NotifyWndProc,
744 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
745 sizeof(PVOID));
746 WinRegisterClass(hab,
747 WC_MINITIME,
748 MiniTimeProc,
749 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
750 sizeof(PVOID) * 2);
751 WinRegisterClass(hab,
752 WC_DATABAR,
753 DataProc, CS_SIZEREDRAW, sizeof(PVOID));
754 WinRegisterClass(hab,
755 WC_TREEOPENBUTTON,
756 OpenButtonProc,
757 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
758 sizeof(PVOID));
759 WinRegisterClass(hab,
760 WC_AUTOVIEW,
761 AutoViewProc,
762 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
763 sizeof(PVOID));
764 WinRegisterClass(hab,
765 WC_LED,
766 LEDProc,
767 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
768 sizeof(PVOID));
769
770 /*
771 * set some defaults (note: everything else automatically initialized
772 * to 0)
773 */
774 detailssize = detailsea = detailslwdate = detailslwtime = detailsattr =
775 detailsicon = fAutoTile = fConfirmDelete = fLoadSubject = fUnHilite =
776 fLoadLongnames = fToolbar = fSaveState = fGuessType = fToolbarHelp =
777 fAutoAddDirs = fUseNewViewer = fDataToFore = fDataShowDrives =
778 fSplitStatus = fDragndropDlg = fQuickArcFind = fKeepCmdLine =
779 fMoreButtons = fDrivebar = fCollapseFirst = fSwitchTree =
780 fSwitchTreeExpand = fNoSearch = fCustomFileDlg = fOtherHelp =
781 fSaveMiniCmds = fUserComboBox = fFM2Deletes = fConfirmTarget =
782 fShowTarget = fDrivebarHelp = fCheckMM = TRUE;
783 ulCnrType = CCS_EXTENDSEL;
784 FilesToGet = 128L;
785 AutoviewHeight = 48L;
786 strcpy(printer, "PRN");
787 prnwidth = 80;
788 prnlength = 66;
789 prntmargin = 6;
790 prnbmargin = 6;
791 prnlmargin = 6;
792 prnrmargin = 3;
793 prnspacing = 1;
794 prntabspaces = 8;
795 CollectorsortFlags = sortFlags = SORT_DIRSFIRST;
796
797 // load preferences from profile (INI) file
798 size = sizeof(BOOL);
799 PrfQueryProfileData(fmprof,
800 appname, "ShowTarget", (PVOID) & fShowTarget, &size);
801 size = sizeof(BOOL);
802 PrfQueryProfileData(fmprof, appname, "CheckMM", (PVOID) & fCheckMM, &size);
803 size = sizeof(BOOL);
804 PrfQueryProfileData(fmprof,
805 appname,
806 "ChangeTarget", (PVOID) & fChangeTarget, &size);
807 size = sizeof(BOOL);
808 PrfQueryProfileData(fmprof,
809 appname,
810 "ConfirmTarget", (PVOID) & fConfirmTarget, &size);
811 size = sizeof(BOOL);
812 PrfQueryProfileData(fmprof,
813 FM3Str,
814 "CustomFileDlg", (PVOID) & fCustomFileDlg, &size);
815 size = sizeof(BOOL);
816 PrfQueryProfileData(fmprof,
817 FM3Str, "SaveMiniCmds", (PVOID) & fSaveMiniCmds, &size);
818 size = sizeof(BOOL);
819 PrfQueryProfileData(fmprof,
820 appname, "SaveBigCmds", (PVOID) & fSaveBigCmds, &size);
821 size = sizeof(BOOL);
822 PrfQueryProfileData(fmprof,
823 appname, "NoFoldMenu", (PVOID) & fNoFoldMenu, &size);
824 size = sizeof(BOOL);
825 PrfQueryProfileData(fmprof,
826 FM3Str, "ThreadNotes", (PVOID) & fThreadNotes, &size);
827 size = sizeof(BOOL);
828 PrfQueryProfileData(fmprof, FM3Str, "Prnpagenums", (PVOID) & prnpagenums,
829 &size);
830 size = sizeof(BOOL);
831 PrfQueryProfileData(fmprof, FM3Str, "Prnalt", (PVOID) & prnalt, &size);
832 size = sizeof(BOOL);
833 PrfQueryProfileData(fmprof, FM3Str, "Prnformat", (PVOID) & prnformat,
834 &size);
835 size = sizeof(BOOL);
836 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedbefore",
837 (PVOID) & prnformfeedbefore, &size);
838 size = sizeof(BOOL);
839 PrfQueryProfileData(fmprof,
840 FM3Str,
841 "Prnformfeedafter", (PVOID) & prnformfeedafter, &size);
842 size = sizeof(ULONG);
843 PrfQueryProfileData(fmprof, FM3Str, "Prntabspaces",
844 (PVOID) & prntabspaces, &size);
845 size = sizeof(ULONG);
846 PrfQueryProfileData(fmprof, FM3Str, "Prnwidth", (PVOID) & prnwidth, &size);
847 size = sizeof(ULONG);
848 PrfQueryProfileData(fmprof, FM3Str, "Prnlength", (PVOID) & prnlength,
849 &size);
850 size = sizeof(ULONG);
851 PrfQueryProfileData(fmprof, FM3Str, "Prntmargin", (PVOID) & prntmargin,
852 &size);
853 size = sizeof(ULONG);
854 PrfQueryProfileData(fmprof, FM3Str, "Prnbmargin", (PVOID) & prnbmargin,
855 &size);
856 size = sizeof(ULONG);
857 PrfQueryProfileData(fmprof, FM3Str, "Prnlmargin", (PVOID) & prnlmargin,
858 &size);
859 size = sizeof(ULONG);
860 PrfQueryProfileData(fmprof, FM3Str, "Prnrmargin", (PVOID) & prnrmargin,
861 &size);
862 size = sizeof(ULONG);
863 PrfQueryProfileData(fmprof, FM3Str, "Prnspacing", (PVOID) & prnspacing,
864 &size);
865 size = sizeof(BOOL);
866 PrfQueryProfileData(fmprof, FM3Str, "NoDead", (PVOID) & fNoDead, &size);
867 size = sizeof(BOOL);
868 PrfQueryProfileData(fmprof, FM3Str, "NoFinger", (PVOID) & fNoFinger, &size);
869 size = sizeof(BOOL);
870 PrfQueryProfileData(fmprof, appname, "SwitchTree", (PVOID) & fSwitchTree,
871 &size);
872 size = sizeof(BOOL);
873 PrfQueryProfileData(fmprof, appname, "SwitchTreeExpand",
874 (PVOID) & fSwitchTreeExpand, &size);
875 size = sizeof(BOOL);
876 PrfQueryProfileData(fmprof, appname, "SwitchTreeOnFocus",
877 (PVOID) & fSwitchTreeOnFocus, &size);
878 size = sizeof(BOOL);
879 PrfQueryProfileData(fmprof, appname, "CollapseFirst",
880 (PVOID) & fCollapseFirst, &size);
881 size = sizeof(BOOL);
882 PrfQueryProfileData(fmprof, appname, "FilesInTree",
883 (PVOID) & fFilesInTree, &size);
884 size = sizeof(BOOL);
885 PrfQueryProfileData(fmprof, FM3Str, "TopDir", (PVOID) & fTopDir, &size);
886 size = sizeof(BOOL);
887 PrfQueryProfileData(fmprof, FM3Str, "LookInDir", (PVOID) & fLookInDir,
888 &size);
889 PrfQueryProfileString(fmprof, appname, "DefArc", NULL, szDefArc,
890 sizeof(szDefArc));
891 size = sizeof(ULONG);
892 PrfQueryProfileData(fmprof, FM3Str, "AutoviewHeight",
893 (PVOID) & AutoviewHeight, &size);
894 size = sizeof(BOOL);
895 PrfQueryProfileData(fmprof, FM3Str, "KeepCmdLine", (PVOID) & fKeepCmdLine,
896 &size);
897 if (strcmp(realappname, "FM/4")) {
898 size = sizeof(BOOL);
899 PrfQueryProfileData(fmprof,
900 FM3Str, "MoreButtons", (PVOID) & fMoreButtons, &size);
901 size = sizeof(BOOL);
902 PrfQueryProfileData(fmprof,
903 FM3Str, "Drivebar", (PVOID) & fDrivebar, &size);
904 }
905 else
906 fDrivebar = fMoreButtons = TRUE;
907 size = sizeof(BOOL);
908 PrfQueryProfileData(fmprof,
909 appname, "NoSearch", (PVOID) & fNoSearch, &size);
910 size = sizeof(BOOL);
911 PrfQueryProfileData(fmprof,
912 appname, "GuessType", (PVOID) & fGuessType, &size);
913 size = sizeof(BOOL);
914 PrfQueryProfileData(fmprof,
915 appname, "ViewChild", (PVOID) & fViewChild, &size);
916 size = sizeof(BOOL);
917 PrfQueryProfileData(fmprof, appname, "ShowEnv", (PVOID) & fShowEnv, &size);
918 size = sizeof(BOOL);
919 PrfQueryProfileData(fmprof,
920 appname, "LeaveTree", (PVOID) & fLeaveTree, &size);
921 size = sizeof(BOOL);
922 PrfQueryProfileData(fmprof, FM3Str, "Comments", (PVOID) & fComments, &size);
923 size = sizeof(ULONG);
924 PrfQueryProfileData(fmprof, appname, "WS_ANIMATE", (PVOID) & fwsAnimate,
925 &size);
926 if (fwsAnimate)
927 fwsAnimate = WS_ANIMATE;
928 size = sizeof(ULONG);
929 size = sizeof(BOOL);
930 PrfQueryProfileData(fmprof, appname, "SelectedAlways",
931 (PVOID) & fSelectedAlways, &size);
932 size = sizeof(BOOL);
933 PrfQueryProfileData(fmprof, FM3Str, "ToolbarHelp", (PVOID) & fToolbarHelp,
934 &size);
935 size = sizeof(BOOL);
936 PrfQueryProfileData(fmprof, FM3Str, "OtherHelp", (PVOID) & fOtherHelp,
937 &size);
938 size = sizeof(BOOL);
939 PrfQueryProfileData(fmprof, FM3Str, "DrivebarHelp", (PVOID) & fDrivebarHelp,
940 &size);
941 size = sizeof(BOOL);
942 PrfQueryProfileData(fmprof,
943 appname, "AutoAddDirs", (PVOID) & fAutoAddDirs, &size);
944 size = sizeof(BOOL);
945 PrfQueryProfileData(fmprof,
946 appname,
947 "AutoAddAllDirs", (PVOID) & fAutoAddAllDirs, &size);
948 size = sizeof(BOOL);
949 PrfQueryProfileData(fmprof, FM3Str, "UserListSwitches",
950 (PVOID) & fUserListSwitches, &size);
951 size = sizeof(BOOL);
952 PrfQueryProfileData(fmprof, appname, "UseNewViewer",
953 (PVOID) & fUseNewViewer, &size);
954 size = sizeof(BOOL);
955 PrfQueryProfileData(fmprof, appname, "DefaultDeletePerm",
956 (PVOID) & fDefaultDeletePerm, &size);
957 size = sizeof(BOOL);
958 PrfQueryProfileData(fmprof, FM3Str, "ExternalINIs",
959 (PVOID) & fExternalINIs, &size);
960 size = sizeof(BOOL);
961 PrfQueryProfileData(fmprof, FM3Str, "ExternalCollector",
962 (PVOID) & fExternalCollector, &size);
963 size = sizeof(BOOL);
964 PrfQueryProfileData(fmprof, FM3Str, "ExternalArcboxes",
965 (PVOID) & fExternalArcboxes, &size);
966 size = sizeof(BOOL);
967 PrfQueryProfileData(fmprof, FM3Str, "ExternalViewer",
968 (PVOID) & fExternalViewer, &size);
969 size = sizeof(BOOL);
970 PrfQueryProfileData(fmprof, FM3Str, "UseQProcStat",
971 (PVOID) & fUseQProcStat, &size);
972 size = sizeof(BOOL);
973 PrfQueryProfileData(fmprof, FM3Str, "DataMin", (PVOID) & fDataMin, &size);
974 size = sizeof(BOOL);
975 PrfQueryProfileData(fmprof, appname, "DataToFore", (PVOID) & fDataToFore,
976 &size);
977 size = sizeof(BOOL);
978 PrfQueryProfileData(fmprof, appname, "DataShowDrives",
979 (PVOID) & fDataShowDrives, &size);
980 size = sizeof(BOOL);
981 PrfQueryProfileData(fmprof, appname, "DataInclRemote",
982 (PVOID) & fDataInclRemote, &size);
983 size = sizeof(BOOL);
984 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", (PVOID) & fSplitStatus,
985 &size);
986 size = sizeof(BOOL);
987 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract",
988 (PVOID) & fFolderAfterExtract, &size);
989 size = sizeof(BOOL);
990 PrfQueryProfileData(fmprof, FM3Str, "DullDatabar", (PVOID) & fDullMin,
991 &size);
992 size = sizeof(BOOL);
993 PrfQueryProfileData(fmprof, appname, "BlueLED", (PVOID) & fBlueLED, &size);
994 size = sizeof(BOOL);
995 PrfQueryProfileData(fmprof, appname, "ConfirmDelete",
996 (PVOID) & fConfirmDelete, &size);
997 size = sizeof(BOOL);
998 PrfQueryProfileData(fmprof, FM3Str, "SaveState", (PVOID) & fSaveState,
999 &size);
1000 size = sizeof(BOOL);
1001 PrfQueryProfileData(fmprof, appname, "SyncUpdates", (PVOID) & fSyncUpdates,
1002 &size);
1003 size = sizeof(BOOL);
1004 PrfQueryProfileData(fmprof, appname, "LoadSubject", (PVOID) & fLoadSubject,
1005 &size);
1006 size = sizeof(BOOL);
1007 PrfQueryProfileData(fmprof, appname, "UnHilite", (PVOID) & fUnHilite,
1008 &size);
1009 size = sizeof(BOOL);
1010 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards",
1011 (PVOID) & fTileBackwards, &size);
1012 size = sizeof(BOOL);
1013 PrfQueryProfileData(fmprof, appname, "LoadLongname",
1014 (PVOID) & fLoadLongnames, &size);
1015 size = sizeof(BOOL);
1016 PrfQueryProfileData(fmprof, appname, "VerifyWrites", (PVOID) & fVerify,
1017 &size);
1018 DosSetVerify(fVerify);
1019 size = sizeof(BOOL);
1020 PrfQueryProfileData(fmprof, appname, "DontMoveMouse",
1021 (PVOID) & fDontMoveMouse, &size);
1022 size = sizeof(BOOL);
1023 PrfQueryProfileData(fmprof, appname, "NoIconsFiles",
1024 (PVOID) & fNoIconsFiles, &size);
1025 size = sizeof(BOOL);
1026 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", (PVOID) & fNoIconsDirs,
1027 &size);
1028 size = sizeof(BOOL);
1029 PrfQueryProfileData(fmprof, appname, "ForceUpper", (PVOID) & fForceUpper,
1030 &size);
1031 size = sizeof(BOOL);
1032 PrfQueryProfileData(fmprof, appname, "ForceLower", (PVOID) & fForceLower,
1033 &size);
1034 size = sizeof(BOOL);
1035 PrfQueryProfileData(fmprof, FM3Str, "TextTools", (PVOID) & fTextTools,
1036 &size);
1037 size = sizeof(BOOL);
1038 PrfQueryProfileData(fmprof, FM3Str, "ToolTitles", (PVOID) & fToolTitles,
1039 &size);
1040 size = sizeof(BOOL);
1041 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", (PVOID) & fDCOpens,
1042 &size);
1043 size = sizeof(BOOL);
1044 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon",
1045 (PVOID) & fLinkSetsIcon, &size);
1046 size = sizeof(INT);
1047 PrfQueryProfileData(fmprof, appname, "Sort", (PVOID) & sortFlags, &size);
1048 size = sizeof(INT);
1049 PrfQueryProfileData(fmprof, appname, "TreeSort", (PVOID) & TreesortFlags,
1050 &size);
1051 size = sizeof(INT);
1052 PrfQueryProfileData(fmprof,
1053 appname,
1054 "CollectorSort", (PVOID) & CollectorsortFlags, &size);
1055 size = sizeof(targetdir);
1056 PrfQueryProfileData(fmprof, appname, "Targetdir", (PVOID) targetdir, &size);
1057 if (!IsValidDir(targetdir))
1058 *targetdir = 0;
1059 size = sizeof(extractpath);
1060 PrfQueryProfileData(fmprof,
1061 appname, "ExtractPath", (PVOID) extractpath, &size);
1062 if (!IsValidDir(extractpath))
1063 *extractpath = 0;
1064 size = sizeof(printer);
1065 PrfQueryProfileData(fmprof, appname, "Printer", (PVOID) printer, &size);
1066 size = sizeof(dircompare);
1067 PrfQueryProfileData(fmprof, appname, "DirCompare", (PVOID) dircompare,
1068 &size);
1069 size = sizeof(viewer);
1070 PrfQueryProfileData(fmprof, appname, "Viewer", (PVOID) viewer, &size);
1071 size = sizeof(editor);
1072 PrfQueryProfileData(fmprof, appname, "Editor", (PVOID) editor, &size);
1073 size = sizeof(binview);
1074 PrfQueryProfileData(fmprof, appname, "BinView", (PVOID) binview, &size);
1075 size = sizeof(bined);
1076 PrfQueryProfileData(fmprof, appname, "BinEd", (PVOID) bined, &size);
1077 size = sizeof(compare);
1078 PrfQueryProfileData(fmprof, appname, "Compare", (PVOID) compare, &size);
1079 size = sizeof(virus);
1080 PrfQueryProfileData(fmprof, appname, "Virus", (PVOID) virus, &size);
1081 size = sizeof(ftprun);
1082 PrfQueryProfileData(fmprof, appname, "FTPRun", (PVOID) ftprun, &size);
1083 if (!*ftprun && !size)
1084 strcpy(ftprun, "ftppm.exe");
1085 size = sizeof(httprun);
1086 PrfQueryProfileData(fmprof, appname, "HTTPRun", (PVOID) httprun, &size);
1087 if (!*httprun && !size)
1088 strcpy(httprun, "explore.exe -q");
1089 size = sizeof(lasttoolbox);
1090 PrfQueryProfileData(fmprof, FM3Str, "LastToolBox", (PVOID) lasttoolbox,
1091 &size);
1092 size = sizeof(BOOL);
1093 PrfQueryProfileData(fmprof, appname, "FollowTree", (PVOID) & fFollowTree,
1094 &size);
1095 size = sizeof(BOOL);
1096 PrfQueryProfileData(fmprof, appname, "StartMaximized",
1097 (PVOID) & fStartMaximized, &size);
1098 if (!fStartMaximized) {
1099 size = sizeof(BOOL);
1100 PrfQueryProfileData(fmprof, appname, "StartMinimized",
1101 (PVOID) & fStartMinimized, &size);
1102 }
1103 size = sizeof(BOOL);
1104 PrfQueryProfileData(fmprof, appname, "DefaultCopy", (PVOID) & fCopyDefault,
1105 &size);
1106 size = sizeof(BOOL);
1107 PrfQueryProfileData(fmprof, appname, "IdleCopy", (PVOID) & fRealIdle,
1108 &size);
1109 size = sizeof(BOOL);
1110 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible",
1111 (PVOID) & fArcStuffVisible, &size);
1112 size = sizeof(BOOL);
1113 PrfQueryProfileData(fmprof, FM3Str, "NoTreeGap", (PVOID) & fNoTreeGap,
1114 &size);
1115 size = sizeof(BOOL);
1116 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS",
1117 (PVOID) & fVTreeOpensWPS, &size);
1118 size = sizeof(BOOL);
1119 PrfQueryProfileData(fmprof, appname, "RemoteBug", (PVOID) & fRemoteBug,
1120 &size);
1121 size = sizeof(BOOL);
1122 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg",
1123 (PVOID) & fDragndropDlg, &size);
1124 size = sizeof(BOOL);
1125 PrfQueryProfileData(fmprof, FM3Str, "UserComboBox", (PVOID) & fUserComboBox,
1126 &size);
1127 size = sizeof(BOOL);
1128 PrfQueryProfileData(fmprof, FM3Str, "MinDirOnOpen", (PVOID) & fMinOnOpen,
1129 &size);
1130 size = sizeof(BOOL);
1131 PrfQueryProfileData(fmprof, appname, "QuickArcFind",
1132 (PVOID) & fQuickArcFind, &size);
1133 size = sizeof(BOOL);
1134 PrfQueryProfileData(fmprof, FM3Str, "NoRemovableScan",
1135 (PVOID) & fNoRemovableScan, &size);
1136 size = sizeof(ULONG);
1137 PrfQueryProfileData(fmprof, FM3Str, "NoBrokenNotify",
1138 (PVOID) & NoBrokenNotify, &size);
1139 size = sizeof(ULONG);
1140 PrfQueryProfileData(fmprof, appname, "ContainerType", (PVOID) & ulCnrType,
1141 &size);
1142 size = sizeof(ULONG);
1143 PrfQueryProfileData(fmprof, appname, "FilesToGet", (PVOID) & FilesToGet,
1144 &size);
1145 size = sizeof(BOOL);
1146 PrfQueryProfileData(fmprof, FM3Str, "AutoView", (PVOID) & fAutoView, &size);
1147 size = sizeof(BOOL);
1148 PrfQueryProfileData(fmprof, FM3Str, "FM2Deletes", (PVOID) & fFM2Deletes,
1149 &size);
1150
1151 /* load pointers and icons we use */
1152 hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE);
1153 hptrBusy = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
1154 hptrNS = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZENS, FALSE);
1155 hptrEW = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE);
1156 hptrFloppy = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FLOPPY_ICON);
1157 hptrDrive = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DRIVE_ICON);
1158 hptrRemovable = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOVABLE_ICON);
1159 hptrCDROM = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, CDROM_ICON);
1160 hptrFile = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_ICON);
1161 hptrDir = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DIR_FRAME);
1162 hptrArc = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ARC_FRAME);
1163 hptrArt = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ART_ICON);
1164 hptrSystem = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_SYSTEM_ICON);
1165 hptrHidden = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_HIDDEN_ICON);
1166 hptrReadonly = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_READONLY_ICON);
1167 hptrLast = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, LASTITEM_ICON);
1168 hptrRemote = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOTE_ICON);
1169 hptrVirtual = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, VIRTUAL_ICON);
1170 hptrRamdisk = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, RAMDISK_ICON);
1171 if (!fNoDead)
1172 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER_ICON);
1173 else
1174 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER2_ICON);
1175 hptrApp = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, APP_ICON);
1176 hptrDunno = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DUNNO_ICON);
1177 hptrEnv = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ENV_ICON);
1178 hptrZipstrm = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ZIPSTREAM_ICON);
1179
1180 // set up color array used by seeall.c and newview.c color dialog
1181
1182 standardcolors[0] = CLR_WHITE;
1183 standardcolors[1] = CLR_BLACK;
1184 standardcolors[2] = CLR_BLUE;
1185 standardcolors[3] = CLR_RED;
1186 standardcolors[4] = CLR_PINK;
1187 standardcolors[5] = CLR_GREEN;
1188 standardcolors[6] = CLR_CYAN;
1189 standardcolors[7] = CLR_YELLOW;
1190 standardcolors[8] = CLR_DARKGRAY;
1191 standardcolors[9] = CLR_DARKBLUE;
1192 standardcolors[10] = CLR_DARKRED;
1193 standardcolors[11] = CLR_DARKPINK;
1194 standardcolors[12] = CLR_DARKGREEN;
1195 standardcolors[13] = CLR_DARKCYAN;
1196 standardcolors[14] = CLR_BROWN;
1197 standardcolors[15] = CLR_PALEGRAY;
1198
1199 return TRUE;
1200}
1201
1202HWND StartFM3(HAB hab, INT argc, CHAR ** argv)
1203{
1204 HWND hwndFrame;
1205 HWND hwndClient;
1206 UINT x;
1207 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
1208 FCF_SIZEBORDER | FCF_MINMAX |
1209 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
1210
1211 for (x = 1; x < argc; x++) {
1212 if (*argv[x] == '~' && !argv[x][1])
1213 fReminimize = TRUE;
1214 if (*argv[x] == '+' && !argv[x][1])
1215 fLogFile = TRUE;
1216 if (*argv[x] == '-') {
1217 if (!argv[x][1])
1218 fNoSaveState = TRUE;
1219 else
1220 strcpy(profile, &argv[x][1]);
1221 }
1222 }
1223
1224 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
1225 WS_VISIBLE,
1226 &FrameFlags,
1227 WC_MAINWND,
1228 NULL,
1229 WS_VISIBLE | WS_ANIMATE,
1230 FM3ModHandle, MAIN_FRAME, &hwndClient);
1231 if (hwndFrame) {
1232 WinSetWindowUShort(hwndFrame, QWS_ID, MAIN_FRAME);
1233 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos", hwndFrame)) {
1234
1235 ULONG fl = SWP_MOVE | SWP_SIZE;
1236 RECTL rcl;
1237 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1238 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
1239
1240 WinQueryWindowRect(HWND_DESKTOP, &rcl);
1241 rcl.yBottom += icz;
1242 rcl.yTop -= bsz;
1243 rcl.xLeft += bsz;
1244 rcl.xRight -= bsz;
1245 WinSetWindowPos(hwndFrame,
1246 HWND_TOP,
1247 rcl.xLeft,
1248 rcl.yBottom,
1249 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
1250 }
1251 if (fLogFile)
1252 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
1253 if (hwndHelp)
1254 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1255 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
1256 }
1257 return hwndFrame;
1258}
1259
1260int CheckVersion(int vermajor, int verminor)
1261{
1262 int ok = 0;
1263
1264 // fixme to do useful check - was missing in base source
1265
1266#if 0
1267 if (vermajor && verminor) {
1268 *vermajor = VERMAJOR;
1269 *verminor = VERMINOR;
1270 ok = 1;
1271 }
1272#endif
1273
1274 ok = 1;
1275
1276 return ok;
1277}
Note: See TracBrowser for help on using the repository browser.