source: trunk/dll/init.c@ 627

Last change on this file since 627 was 627, checked in by Gregg Young, 18 years ago

Eliminate global fAddUtils so can search both path and \utils for FM2PLAY.EXE & Image.exe

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 39.5 KB
Line 
1
2/***********************************************************************
3
4 $Id: init.c 627 2007-04-21 19:00:20Z gyoung $
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++;
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 = 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 _fcloseall();
303
304 save_dir(s);
305 if (s[strlen(s) - 1] != '\\')
306 strcat(s, "\\");
307 enddir = &s[strlen(s)];
308 if (*ArcTempRoot) {
309 strcat(s, ArcTempRoot);
310 strcat(s, "*");
311 search_handle = HDIR_CREATE;
312 num_matches = 1L;
313 if (!DosFindFirst(s,
314 &search_handle,
315 FILE_NORMAL | FILE_DIRECTORY |
316 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
317 FILE_ARCHIVED,
318 &f, sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
319 do {
320 strcpy(enddir, f.achName);
321 if (f.attrFile & FILE_DIRECTORY) {
322 wipeallf("%s\\*", s);
323 DosDeleteDir(s);
324 }
325 else
326 unlinkf("%s", s);
327 }
328 while (!DosFindNext(search_handle,
329 &f, sizeof(FILEFINDBUF3), &num_matches));
330 DosFindClose(search_handle);
331 }
332 }
333
334 save_dir(s);
335 if (s[strlen(s) - 1] != '\\')
336 strcat(s, "\\");
337 enddir = &s[strlen(s)];
338 strcat(s, LISTTEMPROOT);
339 strcat(s, "???");
340 search_handle = HDIR_CREATE;
341 num_matches = 1L;
342 if (!DosFindFirst(s,
343 &search_handle,
344 FILE_NORMAL | FILE_DIRECTORY |
345 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
346 FILE_ARCHIVED,
347 &f, sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
348 do {
349 if (!(f.attrFile & FILE_DIRECTORY)) {
350 strcpy(enddir, f.achName);
351 unlinkf("%s", s);
352 }
353 }
354 while (!DosFindNext(search_handle,
355 &f, sizeof(FILEFINDBUF3), &num_matches));
356 DosFindClose(search_handle);
357 }
358
359 DosForceDelete("$FM2PLAY.$$$");
360
361 EndNote();
362
363 if (FM3ModHandle)
364 DosFreeModule(FM3ModHandle);
365
366 DosExitList(EXLST_REMOVE, DeInitFM3DLL);
367}
368
369BOOL InitFM3DLL(HAB hab, int argc, char **argv)
370{
371 /*
372 * this function should be called by any application using this DLL right
373 * after setting up a message queue
374 */
375
376 CLASSINFO clinfo;
377 APIRET rc;
378 APIRET rcl = 1;
379 APIRET rcq = 1;
380 PFN pfnResVersion = (PFN) NULL;
381 ULONG RVMajor = 0;
382 ULONG RVMinor = 0;
383 ULONG ret = 0;
384 FILESTATUS3 fsa;
385 CHAR *env;
386 CHAR dllfile[CCHMAXPATH];
387 ULONG size;
388
389 if (!StringsLoaded()) {
390 saymsg(MB_ENTER,
391 HWND_DESKTOP,
392 "Error",
393 "FM3RES.STR isn't in right format, at least "
394 "for this version of FM/2.");
395 return FALSE;
396 }
397
398 strcpy(dllfile, "FM3RES");
399 env = getenv("FM3INI");
400 if (env) {
401 FILESTATUS3 fsa;
402 APIRET rc;
403
404 DosError(FERR_DISABLEHARDERR);
405 rc = DosQueryPathInfo(env, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
406 if (!rc) {
407 if (fsa.attrFile & FILE_DIRECTORY) {
408 strcpy(dllfile, env);
409 if (dllfile[strlen(dllfile) - 1] != '\\')
410 strcat(dllfile, "\\");
411 strcat(dllfile, "FM3RES");
412 DosError(FERR_DISABLEHARDERR);
413 if (DosQueryPathInfo(dllfile, FIL_STANDARD, &fsa, sizeof(fsa)))
414 strcpy(dllfile, "FM3RES");
415 }
416 }
417 }
418 rcl = DosLoadModule(NULL, 0, dllfile, &FM3ModHandle);
419 if (rcl) {
420 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
421 HWND_DESKTOP,
422 GetPString(IDS_ERRORTEXT), GetPString(IDS_FM3RESERROR1TEXT));
423 return FALSE;
424 }
425 else {
426 rc = DosExitList(EXLST_ADD, DeInitFM3DLL);
427 if (rc) {
428 Dos_Error(MB_ENTER,
429 rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosExitList failed");
430 }
431 rcq = DosQueryProcAddr(FM3ModHandle, 1, "ResVersion", &pfnResVersion);
432 if (!rcq)
433 ret = pfnResVersion(&RVMajor, &RVMinor);
434 }
435
436 if (RVMajor < VERMAJOR || (RVMajor == VERMAJOR && RVMinor < VERMINOR)) {
437 saymsg(MB_ENTER,
438 HWND_DESKTOP,
439 GetPString(IDS_ERRORTEXT),
440 GetPString(IDS_FM3RESERROR2TEXT),
441 !rcq ?
442 GetPString(IDS_FM3RESERROR3TEXT) :
443 !rcl ?
444 GetPString(IDS_FM3RESERROR4TEXT) :
445 GetPString(IDS_FM3RESERROR5TEXT), RVMajor, RVMinor, rcl, rcq, ret);
446 return FALSE;
447 }
448
449 ArgDriveFlags(argc, argv);
450 FillInDriveFlags(NULL);
451
452 /*{ Removed so can use either path or \utils for fm2play.exe and image.exe
453 try to ensure that FM/2 Utilities are available
454 CHAR curpath[CCHMAXPATH + 8], *env;
455 FILESTATUS3 fs3;
456
457 save_dir2(curpath);
458 strcat(curpath, "\\UTILS");
459 if (!DosQueryPathInfo(curpath,
460 FIL_STANDARD,
461 &fs3,
462 sizeof(fs3)) && (fs3.attrFile & FILE_DIRECTORY)) {
463 env = getenv("PATH");
464 if (env) {
465 if (!stristr(curpath, env))
466 fAddUtils = TRUE;
467 }
468 }
469 } */
470 if (!*profile)
471 strcpy(profile, "FM3.INI");
472 mypid = getpid();
473 /* give default appname if none set by caller */
474 if (!*appname)
475 strcpy(appname, FM3Str);
476 /* save appname; may be reset below */
477 strcpy(realappname, appname);
478 if (!strcmp(appname, FM3Str))
479 DosSetMaxFH(100L);
480 else if (!strcmp(appname, "VDir") ||
481 !strcmp(appname, "VTree") ||
482 !strcmp(appname, "VCollect") ||
483 !strcmp(appname, "SEEALL") || !strcmp(appname, "FM/4"))
484 DosSetMaxFH(60L);
485 else
486 DosSetMaxFH(40L);
487
488 if (DosQuerySysInfo(QSV_VERSION_MAJOR,
489 QSV_VERSION_MINOR,
490 (PVOID) OS2ver, (ULONG) sizeof(OS2ver))) {
491 OS2ver[0] = 2;
492 OS2ver[1] = 1;
493 }
494
495 /* set up default root names for temp archive goodies */
496 if (!fAmAV2)
497 strcpy(ArcTempRoot, "$FM$ARC$");
498 else
499 strcpy(ArcTempRoot, "$AV$ARC$");
500
501 /* initialize random number generator */
502 srand(time(NULL) + clock());
503
504 priority_bumped();
505
506 /* _heapmin() is done in a separate thread -- start it */
507 if (_beginthread(HeapThread, NULL, 32768, NULL) == -1) {
508 Runtime_Error(pszSrcFile, __LINE__,
509 GetPString(IDS_COULDNTSTARTTHREADTEXT));
510 return FALSE;
511 }
512 /* timer messages are sent from a separate thread -- start it */
513 if (!StartTimer())
514 return FALSE;
515
516 /* are we the workplace shell? */
517 env = getenv("WORKPLACE__PROCESS");
518 if (!env || stricmp(env, "NO"))
519 fWorkPlace = TRUE;
520
521 if ((!strchr(profile, '\\') && !strchr(profile, ':')) ||
522 !(fmprof = PrfOpenProfile((HAB) 0, profile))) {
523 /* figure out where to put INI file... */
524 CHAR *env, inipath[CCHMAXPATH];
525
526 DosError(FERR_DISABLEHARDERR);
527 save_dir2(HomePath);
528 DosError(FERR_DISABLEHARDERR);
529 memset(driveserial, -1, sizeof(driveserial));
530 *inipath = 0;
531 env = getenv("FM3INI");
532 if (env) {
533 strcpy(inipath, env);
534 DosError(FERR_DISABLEHARDERR);
535 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
536 if (!rc) {
537 if (fsa.attrFile & FILE_DIRECTORY) {
538 if (inipath[strlen(inipath) - 1] != '\\')
539 strcat(inipath, "\\");
540 strcat(inipath, profile);
541 }
542 }
543 }
544 if (!env) {
545 env = searchpath(profile);
546 if (!env)
547 env = profile;
548 strcpy(inipath, env);
549 }
550
551 /* in some odd cases the INI file can get set to readonly status */
552 /* here we test it and reset the readonly bit if necessary */
553 if (!*inipath)
554 strcpy(inipath, profile);
555 DosError(FERR_DISABLEHARDERR);
556 if (!DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa))) {
557 fIniExisted = TRUE;
558 if (fsa.attrFile & (FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM)) {
559 fsa.attrFile &= (~(FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM));
560 if (DosSetPathInfo(inipath, FIL_STANDARD, (PVOID) & fsa,
561 (ULONG) sizeof(fsa), 0L))
562 saymsg(MB_ENTER,
563 HWND_DESKTOP,
564 GetPString(IDS_ERRORTEXT),
565 GetPString(IDS_INIREADONLYTEXT), inipath);
566 }
567 }
568
569 fmprof = PrfOpenProfile((HAB) 0, inipath);
570 if (!fmprof) {
571 strcpy(inipath, "FM3.INI");
572 fmprof = PrfOpenProfile((HAB) 0, inipath);
573 }
574
575 if (!fmprof) {
576 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
577 "PrfOpenProfile failed");
578 return FALSE;
579 }
580 }
581
582 FindSwapperDat();
583
584 size = sizeof(BOOL);
585 PrfQueryProfileData(fmprof,
586 FM3Str,
587 "SeparateParms", (PVOID) & fSeparateParms, &size);
588 if (!fSeparateParms)
589 strcpy(appname, FM3Str);
590
591 /* start help */
592 memset(&hini, 0, sizeof(HELPINIT));
593 hini.cb = sizeof(HELPINIT);
594 hini.ulReturnCode = 0L;
595 hini.pszTutorialName = NULL;
596 hini.phtHelpTable = (PHELPTABLE) MAKELONG(ID_HELPTABLE, 0xffff);
597 hini.hmodAccelActionBarModule = (HMODULE) 0;
598 hini.idAccelTable = 0;
599 hini.idActionBar = 0;
600 hini.pszHelpWindowTitle = GetPString(IDS_FM2HELPTITLETEXT);
601 hini.fShowPanelId = CMIC_HIDE_PANEL_ID;
602 hini.pszHelpLibraryName = "FM3.HLP";
603 hwndHelp = WinCreateHelpInstance(hab, &hini);
604 if (!hwndHelp) {
605 static CHAR helppath[CCHMAXPATH]; // fixme to be local?
606
607 env = getenv("FM3INI");
608 if (env) {
609 FILESTATUS3 fsa;
610 APIRET rc;
611
612 strcpy(helppath, env);
613 DosError(FERR_DISABLEHARDERR);
614 rc =
615 DosQueryPathInfo(helppath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
616 if (!rc) {
617 if (fsa.attrFile & FILE_DIRECTORY) {
618 if (helppath[strlen(helppath) - 1] != '\\')
619 strcat(helppath, "\\");
620 strcat(helppath, "FM3.HLP");
621 hini.pszHelpLibraryName = helppath;
622 hwndHelp = WinCreateHelpInstance(hab, &hini);
623 }
624 }
625 }
626 }
627 if (!hwndHelp) {
628 saymsg(MB_ENTER | MB_ICONEXCLAMATION,
629 HWND_DESKTOP,
630 GetPString(IDS_FM2TROUBLETEXT),
631 GetPString(IDS_CANTLOADHELPTEXT),
632 GetPString(IDS_NOHELPACCEPTTEXT));
633 }
634
635 /* a couple of default window procs so we don't have to look them up later */
636 if (WinQueryClassInfo(hab, WC_CONTAINER, &clinfo))
637 PFNWPCnr = clinfo.pfnWindowProc;
638 // saymsg(MB_ENTER,HWND_DESKTOP,"Container flags:","%08lx",clinfo.flClassStyle);
639 if (WinQueryClassInfo(hab, WC_FRAME, &clinfo))
640 PFNWPFrame = clinfo.pfnWindowProc;
641 // saymsg(MB_ENTER,HWND_DESKTOP,"Frame flags:","%08lx",clinfo.flClassStyle);
642 if (WinQueryClassInfo(hab, WC_BUTTON, &clinfo))
643 PFNWPButton = clinfo.pfnWindowProc;
644 // saymsg(MB_ENTER,HWND_DESKTOP,"Button flags:","%08lx",clinfo.flClassStyle);
645 if (WinQueryClassInfo(hab, WC_STATIC, &clinfo))
646 PFNWPStatic = clinfo.pfnWindowProc;
647 // saymsg(MB_ENTER,HWND_DESKTOP,"Static flags:","%08lx",clinfo.flClassStyle);
648 if (WinQueryClassInfo(hab, WC_MLE, &clinfo))
649 PFNWPMLE = clinfo.pfnWindowProc;
650 // saymsg(MB_ENTER,HWND_DESKTOP,"MLE flags:","%08lx",clinfo.flClassStyle);
651 if (!PFNWPCnr || !PFNWPFrame || !PFNWPButton || !PFNWPStatic || !PFNWPMLE) {
652 Runtime_Error(pszSrcFile, __LINE__, "WinQueryClassInfo");
653 return FALSE;
654 }
655
656 /* register window classes we use */
657 WinRegisterClass(hab,
658 WC_MAINWND,
659 MainWndProc,
660 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 8);
661 WinRegisterClass(hab,
662 WC_MAINWND2,
663 MainWndProc2,
664 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 4);
665 WinRegisterClass(hab,
666 WC_TREECONTAINER,
667 TreeClientWndProc,
668 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
669 WinRegisterClass(hab,
670 WC_DIRCONTAINER,
671 DirClientWndProc,
672 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
673 WinRegisterClass(hab,
674 WC_COLLECTOR,
675 CollectorClientWndProc,
676 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
677 WinRegisterClass(hab,
678 WC_ARCCONTAINER,
679 ArcClientWndProc,
680 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
681 WinRegisterClass(hab,
682 WC_MLEEDITOR,
683 MLEEditorProc,
684 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
685 WinRegisterClass(hab,
686 WC_INIEDITOR,
687 IniProc,
688 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
689 WinRegisterClass(hab,
690 WC_TOOLBACK,
691 ToolBackProc, CS_SIZEREDRAW, sizeof(PVOID));
692 WinRegisterClass(hab,
693 WC_DRIVEBACK,
694 DriveBackProc,
695 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
696 sizeof(PVOID));
697 WinRegisterClass(hab,
698 WC_SEEALL,
699 SeeAllWndProc,
700 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
701 WinRegisterClass(hab,
702 WC_NEWVIEW,
703 ViewWndProc,
704 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
705 WinRegisterClass(hab,
706 WC_TOOLBUTTONS,
707 ChildButtonProc,
708 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
709 sizeof(PVOID));
710 WinRegisterClass(hab,
711 WC_DRIVEBUTTONS,
712 DriveProc,
713 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
714 sizeof(PVOID));
715 WinRegisterClass(hab,
716 WC_BUBBLE,
717 BubbleProc,
718 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
719 sizeof(ULONG) * 2);
720 WinRegisterClass(hab,
721 WC_STATUS,
722 StatusProc,
723 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
724 sizeof(ULONG));
725 WinRegisterClass(hab,
726 WC_DIRSTATUS,
727 DirTextProc,
728 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
729 sizeof(ULONG));
730 WinRegisterClass(hab,
731 WC_TREESTATUS,
732 TreeStatProc,
733 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
734 sizeof(ULONG));
735 WinRegisterClass(hab,
736 WC_ARCSTATUS,
737 ArcTextProc,
738 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
739 sizeof(ULONG));
740 WinRegisterClass(hab,
741 WC_COLSTATUS,
742 CollectorTextProc,
743 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
744 sizeof(ULONG));
745 WinRegisterClass(hab,
746 WC_SEESTATUS,
747 SeeStatusProc,
748 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
749 sizeof(ULONG));
750 WinRegisterClass(hab,
751 WC_VIEWSTATUS,
752 ViewStatusProc,
753 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
754 sizeof(ULONG));
755 WinRegisterClass(hab,
756 WC_ERRORWND,
757 NotifyWndProc,
758 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
759 sizeof(PVOID));
760 WinRegisterClass(hab,
761 WC_MINITIME,
762 MiniTimeProc,
763 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
764 sizeof(PVOID) * 2);
765 WinRegisterClass(hab,
766 WC_DATABAR,
767 DataProc, CS_SIZEREDRAW, sizeof(PVOID));
768 WinRegisterClass(hab,
769 WC_TREEOPENBUTTON,
770 OpenButtonProc,
771 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
772 sizeof(PVOID));
773 WinRegisterClass(hab,
774 WC_AUTOVIEW,
775 AutoViewProc,
776 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
777 sizeof(PVOID));
778 WinRegisterClass(hab,
779 WC_LED,
780 LEDProc,
781 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
782 sizeof(PVOID));
783
784 /*
785 * set some defaults (note: everything else automatically initialized
786 * to 0)
787 */
788 detailssize = detailsea = detailslwdate = detailslwtime = detailsattr =
789 detailsicon = fAutoTile = fConfirmDelete = fLoadSubject = fUnHilite =
790 fLoadLongnames = fToolbar = fSaveState = fGuessType = fToolbarHelp =
791 fAutoAddDirs = fUseNewViewer = fDataToFore = fDataShowDrives =
792 fSplitStatus = fDragndropDlg = fQuickArcFind = fKeepCmdLine =
793 fMoreButtons = fDrivebar = fCollapseFirst = fSwitchTree =
794 fSwitchTreeExpand = fNoSearch = fCustomFileDlg = fOtherHelp =
795 fSaveMiniCmds = fUserComboBox = fFM2Deletes = fConfirmTarget =
796 fShowTarget = fDrivebarHelp = fCheckMM = TRUE;
797 ulCnrType = CCS_EXTENDSEL;
798 FilesToGet = 128L;
799 AutoviewHeight = 48L;
800 strcpy(printer, "PRN");
801 prnwidth = 80;
802 prnlength = 66;
803 prntmargin = 6;
804 prnbmargin = 6;
805 prnlmargin = 6;
806 prnrmargin = 3;
807 prnspacing = 1;
808 prntabspaces = 8;
809 CollectorsortFlags = sortFlags = SORT_DIRSFIRST;
810
811 // load preferences from profile (INI) file
812 size = sizeof(BOOL);
813 PrfQueryProfileData(fmprof,
814 appname, "ShowTarget", (PVOID) & fShowTarget, &size);
815 size = sizeof(BOOL);
816 PrfQueryProfileData(fmprof, appname, "CheckMM", (PVOID) & fCheckMM, &size);
817 size = sizeof(BOOL);
818 PrfQueryProfileData(fmprof,
819 appname,
820 "ChangeTarget", (PVOID) & fChangeTarget, &size);
821 size = sizeof(BOOL);
822 PrfQueryProfileData(fmprof,
823 appname,
824 "ConfirmTarget", (PVOID) & fConfirmTarget, &size);
825 size = sizeof(BOOL);
826 PrfQueryProfileData(fmprof,
827 FM3Str,
828 "CustomFileDlg", (PVOID) & fCustomFileDlg, &size);
829 size = sizeof(BOOL);
830 PrfQueryProfileData(fmprof,
831 FM3Str, "SaveMiniCmds", (PVOID) & fSaveMiniCmds, &size);
832 size = sizeof(BOOL);
833 PrfQueryProfileData(fmprof,
834 appname, "SaveBigCmds", (PVOID) & fSaveBigCmds, &size);
835 size = sizeof(BOOL);
836 PrfQueryProfileData(fmprof,
837 appname, "NoFoldMenu", (PVOID) & fNoFoldMenu, &size);
838 size = sizeof(BOOL);
839 PrfQueryProfileData(fmprof,
840 FM3Str, "ThreadNotes", (PVOID) & fThreadNotes, &size);
841 size = sizeof(BOOL);
842 PrfQueryProfileData(fmprof, FM3Str, "Prnpagenums", (PVOID) & prnpagenums,
843 &size);
844 size = sizeof(BOOL);
845 PrfQueryProfileData(fmprof, FM3Str, "Prnalt", (PVOID) & prnalt, &size);
846 size = sizeof(BOOL);
847 PrfQueryProfileData(fmprof, FM3Str, "Prnformat", (PVOID) & prnformat,
848 &size);
849 size = sizeof(BOOL);
850 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedbefore",
851 (PVOID) & prnformfeedbefore, &size);
852 size = sizeof(BOOL);
853 PrfQueryProfileData(fmprof,
854 FM3Str,
855 "Prnformfeedafter", (PVOID) & prnformfeedafter, &size);
856 size = sizeof(ULONG);
857 PrfQueryProfileData(fmprof, FM3Str, "Prntabspaces",
858 (PVOID) & prntabspaces, &size);
859 size = sizeof(ULONG);
860 PrfQueryProfileData(fmprof, FM3Str, "Prnwidth", (PVOID) & prnwidth, &size);
861 size = sizeof(ULONG);
862 PrfQueryProfileData(fmprof, FM3Str, "Prnlength", (PVOID) & prnlength,
863 &size);
864 size = sizeof(ULONG);
865 PrfQueryProfileData(fmprof, FM3Str, "Prntmargin", (PVOID) & prntmargin,
866 &size);
867 size = sizeof(ULONG);
868 PrfQueryProfileData(fmprof, FM3Str, "Prnbmargin", (PVOID) & prnbmargin,
869 &size);
870 size = sizeof(ULONG);
871 PrfQueryProfileData(fmprof, FM3Str, "Prnlmargin", (PVOID) & prnlmargin,
872 &size);
873 size = sizeof(ULONG);
874 PrfQueryProfileData(fmprof, FM3Str, "Prnrmargin", (PVOID) & prnrmargin,
875 &size);
876 size = sizeof(ULONG);
877 PrfQueryProfileData(fmprof, FM3Str, "Prnspacing", (PVOID) & prnspacing,
878 &size);
879 size = sizeof(BOOL);
880 PrfQueryProfileData(fmprof, FM3Str, "NoDead", (PVOID) & fNoDead, &size);
881 size = sizeof(BOOL);
882 PrfQueryProfileData(fmprof, FM3Str, "NoFinger", (PVOID) & fNoFinger, &size);
883 size = sizeof(BOOL);
884 PrfQueryProfileData(fmprof, appname, "SwitchTree", (PVOID) & fSwitchTree,
885 &size);
886 size = sizeof(BOOL);
887 PrfQueryProfileData(fmprof, appname, "SwitchTreeExpand",
888 (PVOID) & fSwitchTreeExpand, &size);
889 size = sizeof(BOOL);
890 PrfQueryProfileData(fmprof, appname, "SwitchTreeOnFocus",
891 (PVOID) & fSwitchTreeOnFocus, &size);
892 size = sizeof(BOOL);
893 PrfQueryProfileData(fmprof, appname, "CollapseFirst",
894 (PVOID) & fCollapseFirst, &size);
895 size = sizeof(BOOL);
896 PrfQueryProfileData(fmprof, appname, "FilesInTree",
897 (PVOID) & fFilesInTree, &size);
898 size = sizeof(BOOL);
899 PrfQueryProfileData(fmprof, FM3Str, "TopDir", (PVOID) & fTopDir, &size);
900 size = sizeof(BOOL);
901 PrfQueryProfileData(fmprof, FM3Str, "LookInDir", (PVOID) & fLookInDir,
902 &size);
903 PrfQueryProfileString(fmprof, appname, "DefArc", NULL, szDefArc,
904 sizeof(szDefArc));
905 size = sizeof(ULONG);
906 PrfQueryProfileData(fmprof, FM3Str, "AutoviewHeight",
907 (PVOID) & AutoviewHeight, &size);
908 size = sizeof(BOOL);
909 PrfQueryProfileData(fmprof, FM3Str, "KeepCmdLine", (PVOID) & fKeepCmdLine,
910 &size);
911 if (strcmp(realappname, "FM/4")) {
912 size = sizeof(BOOL);
913 PrfQueryProfileData(fmprof,
914 FM3Str, "MoreButtons", (PVOID) & fMoreButtons, &size);
915 size = sizeof(BOOL);
916 PrfQueryProfileData(fmprof,
917 FM3Str, "Drivebar", (PVOID) & fDrivebar, &size);
918 }
919 else
920 fDrivebar = fMoreButtons = TRUE;
921 size = sizeof(BOOL);
922 PrfQueryProfileData(fmprof,
923 appname, "NoSearch", (PVOID) & fNoSearch, &size);
924 size = sizeof(BOOL);
925 PrfQueryProfileData(fmprof,
926 appname, "GuessType", (PVOID) & fGuessType, &size);
927 size = sizeof(BOOL);
928 PrfQueryProfileData(fmprof,
929 appname, "ViewChild", (PVOID) & fViewChild, &size);
930 size = sizeof(BOOL);
931 PrfQueryProfileData(fmprof, appname, "ShowEnv", (PVOID) & fShowEnv, &size);
932 size = sizeof(BOOL);
933 PrfQueryProfileData(fmprof,
934 appname, "LeaveTree", (PVOID) & fLeaveTree, &size);
935 size = sizeof(BOOL);
936 PrfQueryProfileData(fmprof, FM3Str, "Comments", (PVOID) & fComments, &size);
937 size = sizeof(ULONG);
938 PrfQueryProfileData(fmprof, appname, "WS_ANIMATE", (PVOID) & fwsAnimate,
939 &size);
940 if (fwsAnimate)
941 fwsAnimate = WS_ANIMATE;
942 size = sizeof(ULONG);
943 size = sizeof(BOOL);
944 PrfQueryProfileData(fmprof, appname, "SelectedAlways",
945 (PVOID) & fSelectedAlways, &size);
946 size = sizeof(BOOL);
947 PrfQueryProfileData(fmprof, FM3Str, "ToolbarHelp", (PVOID) & fToolbarHelp,
948 &size);
949 size = sizeof(BOOL);
950 PrfQueryProfileData(fmprof, FM3Str, "OtherHelp", (PVOID) & fOtherHelp,
951 &size);
952 size = sizeof(BOOL);
953 PrfQueryProfileData(fmprof, FM3Str, "DrivebarHelp", (PVOID) & fDrivebarHelp,
954 &size);
955 size = sizeof(BOOL);
956 PrfQueryProfileData(fmprof,
957 appname, "AutoAddDirs", (PVOID) & fAutoAddDirs, &size);
958 size = sizeof(BOOL);
959 PrfQueryProfileData(fmprof,
960 appname,
961 "AutoAddAllDirs", (PVOID) & fAutoAddAllDirs, &size);
962 size = sizeof(BOOL);
963 PrfQueryProfileData(fmprof, FM3Str, "UserListSwitches",
964 (PVOID) & fUserListSwitches, &size);
965 size = sizeof(BOOL);
966 PrfQueryProfileData(fmprof, appname, "UseNewViewer",
967 (PVOID) & fUseNewViewer, &size);
968 size = sizeof(BOOL);
969 PrfQueryProfileData(fmprof, appname, "DefaultDeletePerm",
970 (PVOID) & fDefaultDeletePerm, &size);
971 size = sizeof(BOOL);
972 PrfQueryProfileData(fmprof, FM3Str, "ExternalINIs",
973 (PVOID) & fExternalINIs, &size);
974 size = sizeof(BOOL);
975 PrfQueryProfileData(fmprof, FM3Str, "ExternalCollector",
976 (PVOID) & fExternalCollector, &size);
977 size = sizeof(BOOL);
978 PrfQueryProfileData(fmprof, FM3Str, "ExternalArcboxes",
979 (PVOID) & fExternalArcboxes, &size);
980 size = sizeof(BOOL);
981 PrfQueryProfileData(fmprof, FM3Str, "ExternalViewer",
982 (PVOID) & fExternalViewer, &size);
983 size = sizeof(BOOL);
984 PrfQueryProfileData(fmprof, FM3Str, "UseQProcStat",
985 (PVOID) & fUseQProcStat, &size);
986 size = sizeof(BOOL);
987 PrfQueryProfileData(fmprof, FM3Str, "DataMin", (PVOID) & fDataMin, &size);
988 size = sizeof(BOOL);
989 PrfQueryProfileData(fmprof, appname, "DataToFore", (PVOID) & fDataToFore,
990 &size);
991 size = sizeof(BOOL);
992 PrfQueryProfileData(fmprof, appname, "DataShowDrives",
993 (PVOID) & fDataShowDrives, &size);
994 size = sizeof(BOOL);
995 PrfQueryProfileData(fmprof, appname, "DataInclRemote",
996 (PVOID) & fDataInclRemote, &size);
997 size = sizeof(BOOL);
998 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", (PVOID) & fSplitStatus,
999 &size);
1000 size = sizeof(BOOL);
1001 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract",
1002 (PVOID) & fFolderAfterExtract, &size);
1003 size = sizeof(BOOL);
1004 PrfQueryProfileData(fmprof, FM3Str, "DullDatabar", (PVOID) & fDullMin,
1005 &size);
1006 size = sizeof(BOOL);
1007 PrfQueryProfileData(fmprof, appname, "BlueLED", (PVOID) & fBlueLED, &size);
1008 size = sizeof(BOOL);
1009 PrfQueryProfileData(fmprof, appname, "ConfirmDelete",
1010 (PVOID) & fConfirmDelete, &size);
1011 size = sizeof(BOOL);
1012 PrfQueryProfileData(fmprof, FM3Str, "SaveState", (PVOID) & fSaveState,
1013 &size);
1014 size = sizeof(BOOL);
1015 PrfQueryProfileData(fmprof, appname, "SyncUpdates", (PVOID) & fSyncUpdates,
1016 &size);
1017 size = sizeof(BOOL);
1018 PrfQueryProfileData(fmprof, appname, "LoadSubject", (PVOID) & fLoadSubject,
1019 &size);
1020 size = sizeof(BOOL);
1021 PrfQueryProfileData(fmprof, appname, "UnHilite", (PVOID) & fUnHilite,
1022 &size);
1023 size = sizeof(BOOL);
1024 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards",
1025 (PVOID) & fTileBackwards, &size);
1026 size = sizeof(BOOL);
1027 PrfQueryProfileData(fmprof, appname, "LoadLongname",
1028 (PVOID) & fLoadLongnames, &size);
1029 size = sizeof(BOOL);
1030 PrfQueryProfileData(fmprof, appname, "VerifyWrites", (PVOID) & fVerify,
1031 &size);
1032 DosSetVerify(fVerify);
1033 size = sizeof(BOOL);
1034 PrfQueryProfileData(fmprof, appname, "DontMoveMouse",
1035 (PVOID) & fDontMoveMouse, &size);
1036 size = sizeof(BOOL);
1037 PrfQueryProfileData(fmprof, appname, "NoIconsFiles",
1038 (PVOID) & fNoIconsFiles, &size);
1039 size = sizeof(BOOL);
1040 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", (PVOID) & fNoIconsDirs,
1041 &size);
1042 size = sizeof(BOOL);
1043 PrfQueryProfileData(fmprof, appname, "ForceUpper", (PVOID) & fForceUpper,
1044 &size);
1045 size = sizeof(BOOL);
1046 PrfQueryProfileData(fmprof, appname, "ForceLower", (PVOID) & fForceLower,
1047 &size);
1048 size = sizeof(BOOL);
1049 PrfQueryProfileData(fmprof, FM3Str, "TextTools", (PVOID) & fTextTools,
1050 &size);
1051 size = sizeof(BOOL);
1052 PrfQueryProfileData(fmprof, FM3Str, "ToolTitles", (PVOID) & fToolTitles,
1053 &size);
1054 size = sizeof(BOOL);
1055 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", (PVOID) & fDCOpens,
1056 &size);
1057 size = sizeof(BOOL);
1058 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon",
1059 (PVOID) & fLinkSetsIcon, &size);
1060 size = sizeof(INT);
1061 PrfQueryProfileData(fmprof, appname, "Sort", (PVOID) & sortFlags, &size);
1062 size = sizeof(INT);
1063 PrfQueryProfileData(fmprof, appname, "TreeSort", (PVOID) & TreesortFlags,
1064 &size);
1065 size = sizeof(INT);
1066 PrfQueryProfileData(fmprof,
1067 appname,
1068 "CollectorSort", (PVOID) & CollectorsortFlags, &size);
1069 size = sizeof(targetdir);
1070 PrfQueryProfileData(fmprof, appname, "Targetdir", (PVOID) targetdir, &size);
1071 if (!IsValidDir(targetdir))
1072 *targetdir = 0;
1073 size = sizeof(extractpath);
1074 PrfQueryProfileData(fmprof,
1075 appname, "ExtractPath", (PVOID) extractpath, &size);
1076 if (!IsValidDir(extractpath))
1077 *extractpath = 0;
1078 size = sizeof(printer);
1079 PrfQueryProfileData(fmprof, appname, "Printer", (PVOID) printer, &size);
1080 size = sizeof(dircompare);
1081 PrfQueryProfileData(fmprof, appname, "DirCompare", (PVOID) dircompare,
1082 &size);
1083 size = sizeof(viewer);
1084 PrfQueryProfileData(fmprof, appname, "Viewer", (PVOID) viewer, &size);
1085 size = sizeof(editor);
1086 PrfQueryProfileData(fmprof, appname, "Editor", (PVOID) editor, &size);
1087 size = sizeof(binview);
1088 PrfQueryProfileData(fmprof, appname, "BinView", (PVOID) binview, &size);
1089 size = sizeof(bined);
1090 PrfQueryProfileData(fmprof, appname, "BinEd", (PVOID) bined, &size);
1091 size = sizeof(compare);
1092 PrfQueryProfileData(fmprof, appname, "Compare", (PVOID) compare, &size);
1093 size = sizeof(virus);
1094 PrfQueryProfileData(fmprof, appname, "Virus", (PVOID) virus, &size);
1095 size = sizeof(ftprun);
1096 PrfQueryProfileData(fmprof, appname, "FTPRun", (PVOID) ftprun, &size);
1097 if (!*ftprun && !size)
1098 strcpy(ftprun, "ftppm.exe");
1099 size = sizeof(httprun);
1100 PrfQueryProfileData(fmprof, appname, "HTTPRun", (PVOID) httprun, &size);
1101 if (!*httprun && !size)
1102 strcpy(httprun, "explore.exe -q");
1103 size = sizeof(lasttoolbox);
1104 PrfQueryProfileData(fmprof, FM3Str, "LastToolBox", (PVOID) lasttoolbox,
1105 &size);
1106 size = sizeof(BOOL);
1107 PrfQueryProfileData(fmprof, appname, "FollowTree", (PVOID) & fFollowTree,
1108 &size);
1109 size = sizeof(BOOL);
1110 PrfQueryProfileData(fmprof, appname, "StartMaximized",
1111 (PVOID) & fStartMaximized, &size);
1112 if (!fStartMaximized) {
1113 size = sizeof(BOOL);
1114 PrfQueryProfileData(fmprof, appname, "StartMinimized",
1115 (PVOID) & fStartMinimized, &size);
1116 }
1117 size = sizeof(BOOL);
1118 PrfQueryProfileData(fmprof, appname, "DefaultCopy", (PVOID) & fCopyDefault,
1119 &size);
1120 size = sizeof(BOOL);
1121 PrfQueryProfileData(fmprof, appname, "IdleCopy", (PVOID) & fRealIdle,
1122 &size);
1123 size = sizeof(BOOL);
1124 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible",
1125 (PVOID) & fArcStuffVisible, &size);
1126 size = sizeof(BOOL);
1127 PrfQueryProfileData(fmprof, FM3Str, "NoTreeGap", (PVOID) & fNoTreeGap,
1128 &size);
1129 size = sizeof(BOOL);
1130 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS",
1131 (PVOID) & fVTreeOpensWPS, &size);
1132 size = sizeof(BOOL);
1133 PrfQueryProfileData(fmprof, appname, "RemoteBug", (PVOID) & fRemoteBug,
1134 &size);
1135 size = sizeof(BOOL);
1136 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg",
1137 (PVOID) & fDragndropDlg, &size);
1138 size = sizeof(BOOL);
1139 PrfQueryProfileData(fmprof, FM3Str, "UserComboBox", (PVOID) & fUserComboBox,
1140 &size);
1141 size = sizeof(BOOL);
1142 PrfQueryProfileData(fmprof, FM3Str, "MinDirOnOpen", (PVOID) & fMinOnOpen,
1143 &size);
1144 size = sizeof(BOOL);
1145 PrfQueryProfileData(fmprof, appname, "QuickArcFind",
1146 (PVOID) & fQuickArcFind, &size);
1147 size = sizeof(BOOL);
1148 PrfQueryProfileData(fmprof, FM3Str, "NoRemovableScan",
1149 (PVOID) & fNoRemovableScan, &size);
1150 size = sizeof(ULONG);
1151 PrfQueryProfileData(fmprof, FM3Str, "NoBrokenNotify",
1152 (PVOID) & NoBrokenNotify, &size);
1153 size = sizeof(ULONG);
1154 PrfQueryProfileData(fmprof, appname, "ContainerType", (PVOID) & ulCnrType,
1155 &size);
1156 size = sizeof(ULONG);
1157 PrfQueryProfileData(fmprof, appname, "FilesToGet", (PVOID) & FilesToGet,
1158 &size);
1159 size = sizeof(BOOL);
1160 PrfQueryProfileData(fmprof, FM3Str, "AutoView", (PVOID) & fAutoView, &size);
1161 size = sizeof(BOOL);
1162 PrfQueryProfileData(fmprof, FM3Str, "FM2Deletes", (PVOID) & fFM2Deletes,
1163 &size);
1164
1165 /* load pointers and icons we use */
1166 hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE);
1167 hptrBusy = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
1168 hptrNS = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZENS, FALSE);
1169 hptrEW = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE);
1170 hptrFloppy = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FLOPPY_ICON);
1171 hptrDrive = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DRIVE_ICON);
1172 hptrRemovable = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOVABLE_ICON);
1173 hptrCDROM = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, CDROM_ICON);
1174 hptrFile = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_ICON);
1175 hptrDir = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DIR_FRAME);
1176 hptrArc = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ARC_FRAME);
1177 hptrArt = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ART_ICON);
1178 hptrSystem = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_SYSTEM_ICON);
1179 hptrHidden = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_HIDDEN_ICON);
1180 hptrReadonly = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_READONLY_ICON);
1181 hptrLast = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, LASTITEM_ICON);
1182 hptrRemote = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOTE_ICON);
1183 hptrVirtual = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, VIRTUAL_ICON);
1184 hptrRamdisk = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, RAMDISK_ICON);
1185 if (!fNoDead)
1186 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER_ICON);
1187 else
1188 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER2_ICON);
1189 hptrApp = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, APP_ICON);
1190 hptrDunno = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DUNNO_ICON);
1191 hptrEnv = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ENV_ICON);
1192 hptrZipstrm = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ZIPSTREAM_ICON);
1193
1194 // set up color array used by seeall.c and newview.c color dialog
1195
1196 standardcolors[0] = CLR_WHITE;
1197 standardcolors[1] = CLR_BLACK;
1198 standardcolors[2] = CLR_BLUE;
1199 standardcolors[3] = CLR_RED;
1200 standardcolors[4] = CLR_PINK;
1201 standardcolors[5] = CLR_GREEN;
1202 standardcolors[6] = CLR_CYAN;
1203 standardcolors[7] = CLR_YELLOW;
1204 standardcolors[8] = CLR_DARKGRAY;
1205 standardcolors[9] = CLR_DARKBLUE;
1206 standardcolors[10] = CLR_DARKRED;
1207 standardcolors[11] = CLR_DARKPINK;
1208 standardcolors[12] = CLR_DARKGREEN;
1209 standardcolors[13] = CLR_DARKCYAN;
1210 standardcolors[14] = CLR_BROWN;
1211 standardcolors[15] = CLR_PALEGRAY;
1212
1213 return TRUE;
1214}
1215
1216HWND StartFM3(HAB hab, INT argc, CHAR ** argv)
1217{
1218 HWND hwndFrame;
1219 HWND hwndClient;
1220 UINT x;
1221 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
1222 FCF_SIZEBORDER | FCF_MINMAX |
1223 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
1224
1225 for (x = 1; x < argc; x++) {
1226 if (*argv[x] == '~' && !argv[x][1])
1227 fReminimize = TRUE;
1228 if (*argv[x] == '+' && !argv[x][1])
1229 fLogFile = TRUE;
1230 if (*argv[x] == '-') {
1231 if (!argv[x][1])
1232 fNoSaveState = TRUE;
1233 else
1234 strcpy(profile, &argv[x][1]);
1235 }
1236 }
1237
1238 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
1239 WS_VISIBLE,
1240 &FrameFlags,
1241 WC_MAINWND,
1242 NULL,
1243 WS_VISIBLE | WS_ANIMATE,
1244 FM3ModHandle, MAIN_FRAME, &hwndClient);
1245 if (hwndFrame) {
1246 WinSetWindowUShort(hwndFrame, QWS_ID, MAIN_FRAME);
1247 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos", hwndFrame)) {
1248
1249 ULONG fl = SWP_MOVE | SWP_SIZE;
1250 RECTL rcl;
1251 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1252 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
1253
1254 WinQueryWindowRect(HWND_DESKTOP, &rcl);
1255 rcl.yBottom += icz;
1256 rcl.yTop -= bsz;
1257 rcl.xLeft += bsz;
1258 rcl.xRight -= bsz;
1259 WinSetWindowPos(hwndFrame,
1260 HWND_TOP,
1261 rcl.xLeft,
1262 rcl.yBottom,
1263 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
1264 }
1265 if (fLogFile)
1266 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
1267 if (hwndHelp)
1268 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1269 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
1270 }
1271 return hwndFrame;
1272}
1273
1274int CheckVersion(int vermajor, int verminor)
1275{
1276 int ok = 0;
1277
1278 // fixme to do useful check - was missing in base source
1279
1280#if 0
1281 if (vermajor && verminor) {
1282 *vermajor = VERMAJOR;
1283 *verminor = VERMINOR;
1284 ok = 1;
1285 }
1286#endif
1287
1288 ok = 1;
1289
1290 return ok;
1291}
Note: See TracBrowser for help on using the repository browser.