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
RevLine 
[32]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
[627]9 Copyright (c) 2001, 2007 Steven H. Levine
[32]10
[133]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
[179]15 26 May 05 SHL Comments
[189]16 06 Jun 05 SHL indent -i2
[201]17 06 Jun 05 SHL Rework FindSwapperDat for VAC3.65 compat
[339]18 13 Jul 06 SHL Use Runtime_Error
19 13 Jul 06 SHL Sync with current style
[404]20 29 Jul 06 SHL Use xfgets
[526]21 22 Oct 06 GKY Add NDFS32 support
[552]22 18 Feb 07 GKY Add ISOFS, RAMFS support
[593]23 30 Mar 07 GKY Defined golbals for removing GetPString for window class names
[627]24 21 Apr 07 GKY Find FM2Utils by path or utils directory eleminate fAddUtils global
[32]25
26***********************************************************************/
27
[2]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>
[133]44
[2]45#include "fm3dll.h"
46#include "fm3dlg.h"
[133]47#include "datamin.h"
[2]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
[189]55extern int _CRT_init(void);
[2]56extern void _CRT_term(void);
57
[339]58static PSZ pszSrcFile = __FILE__;
[2]59
[189]60VOID FindSwapperDat(VOID)
61{
[201]62 CHAR filename[] = "C:\\CONFIG.SYS";
63 CHAR input[8192];
64 CHAR *p;
65 CHAR *pp;
[189]66 FILE *fp;
[2]67 FILEFINDBUF3 ffb;
[201]68 ULONG nm;
69 ULONG size = sizeof(SwapperDat);
[189]70 HDIR hdir = HDIR_CREATE;
[201]71 APIRET rc = 1;
[2]72
73 *SwapperDat = 0;
[201]74 // Check already known
[2]75 PrfQueryProfileData(fmprof,
[551]76 FM3Str, "SwapperDat", (PVOID) SwapperDat, &size);
77 if (*SwapperDat) {
[201]78 nm = 1;
[2]79 rc = DosFindFirst(SwapperDat,
[189]80 &hdir,
81 FILE_NORMAL | FILE_ARCHIVED |
82 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
[551]83 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
84 if (!rc) {
[2]85 DosFindClose(hdir);
[189]86 fp = fopen(SwapperDat, "r");
[551]87 if (fp) {
[189]88 fclose(fp);
89 *SwapperDat = 0;
[551]90 rc = 1; // Force config.sys scan
[2]91 }
92 }
93 else
94 *SwapperDat = 0;
95 }
[201]96 // If not defined in INI or INI wrong, scan config.sys for SWAPPATH statement
[551]97 if (rc) {
[189]98 if (DosQuerySysInfo(QSV_BOOT_DRIVE,
99 QSV_BOOT_DRIVE,
[551]100 (PVOID) & nm, (ULONG) sizeof(ULONG))) {
101 nm = 3; // Assume drive C:
[201]102 }
[551]103 *filename = (CHAR) nm + '@';
[404]104 fp = xfsopen(filename, "r", SH_DENYNO, pszSrcFile, __LINE__);
[551]105 if (fp) {
[404]106 while (!feof(fp)) {
[551]107 if (!xfgets(input, sizeof(input), fp, pszSrcFile, __LINE__))
[189]108 break;
109 lstrip(input);
[551]110 if (!strnicmp(input, "SWAPPATH", 8)) {
[189]111 p = input + 8;
112 while (*p == ' ')
113 p++;
[551]114 if (*p == '=') {
[189]115 p++;
116 stripcr(p);
117 rstrip(p);
118 while (*p == ' ')
119 p++;
[551]120 if (*p == '\"') {
[189]121 p++;
122 pp = p;
123 while (*pp && *pp != '\"')
124 *pp++;
125 if (*pp)
126 *pp = 0;
127 }
[551]128 else {
[189]129 pp = strchr(p, ' ');
130 if (pp)
131 *pp = 0;
132 }
[551]133 if (*p) {
[189]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;
[201]140 nm = 1;
[189]141 if (!DosFindFirst(SwapperDat,
142 &hdir,
143 FILE_NORMAL | FILE_ARCHIVED |
144 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
[551]145 &ffb, sizeof(ffb), &nm, FIL_STANDARD)) {
[189]146 DosFindClose(hdir);
147 PrfWriteProfileString(fmprof,
[551]148 FM3Str, "SwapperDat", SwapperDat);
[189]149 }
150 else
151 *SwapperDat = 0;
152 break;
153 }
154 }
[551]155 } // if SWAPPATH
156 } // while
[2]157 fclose(fp);
158 }
159 }
160}
161
[189]162unsigned long _System _DLL_InitTerm(unsigned long hModule,
163 unsigned long ulFlag)
164{
[201]165 CHAR *env;
166 CHAR stringfile[CCHMAXPATH];
167 FILESTATUS3 fsa;
168 APIRET rc;
[2]169
[551]170 switch (ulFlag) {
[189]171 case 0:
172 if (_CRT_init() == -1)
173 return 0UL;
174 FM3DllHandle = hModule;
[201]175 strcpy(stringfile, "FM3RES.STR");
176 env = getenv("FM3INI");
[551]177 if (env) {
[201]178 DosError(FERR_DISABLEHARDERR);
[551]179 rc = DosQueryPathInfo(env, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
180 if (!rc) {
181 if (fsa.attrFile & FILE_DIRECTORY) {
[201]182 strcpy(stringfile, env);
183 if (stringfile[strlen(stringfile) - 1] != '\\')
184 strcat(stringfile, "\\");
185 strcat(stringfile, "FM3RES.STR");
186 DosError(FERR_DISABLEHARDERR);
[551]187 if (DosQueryPathInfo(stringfile, FIL_STANDARD, &fsa, sizeof(fsa)))
[201]188 strcpy(stringfile, "FM3RES.STR");
[189]189 }
[2]190 }
[189]191 }
[201]192 LoadStrings(stringfile);
193
[189]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>,"
[551]208 "<DRM_DISCARD,DRF_UNKNOWN>," "<DRM_PRINT,DRF_UNKNOWN>";
[189]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";
[552]218 ISOFS = "ISOFS";
[189]219 FAT32 = "FAT32";
220 HPFS386 = "HPFS386";
221 CBSIFS = "CBSIFS";
[526]222 NDFS32 = "NDFS32";
[552]223 RAMFS = "RAMFS";
[555]224 NTFS = "NTFS";
[593]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
[189]255 /* end of strings */
256 memset(&RGBBLACK, 0, sizeof(RGB2));
257 RGBGREY.bRed = RGBGREY.bGreen = RGBGREY.bBlue = 204;
258 RGBGREY.fcOptions = 0;
[551]259 FM3UL = *(ULONG *) FM3Str;
[189]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;
[2]271 }
272 return 1UL;
273}
274
[189]275VOID APIENTRY DeInitFM3DLL(ULONG why)
276{
[2]277 /* cleanup */
[189]278 static CHAR s[CCHMAXPATH];
279 CHAR *enddir;
280 HDIR search_handle;
281 ULONG num_matches;
[2]282 static FILEFINDBUF3 f;
283
284 StopTimer();
285 StopPrinting = 1;
286
[189]287 if (LogFileHandle)
[2]288 fclose(LogFileHandle);
289
[551]290 if (fmprof) {
[2]291 PrfCloseProfile(fmprof);
[189]292 fmprof = (HINI) 0;
[551]293 if (fIniExisted) {
[2]294 DosError(FERR_DISABLEHARDERR);
[551]295 DosCopy("FM3.INI", "FM3INI.BAK", DCPY_EXISTING);
[2]296 }
297 }
298
[189]299 if (fToolsChanged)
[2]300 save_tools(NULL);
301
302 _fcloseall();
303
304 save_dir(s);
[189]305 if (s[strlen(s) - 1] != '\\')
306 strcat(s, "\\");
[2]307 enddir = &s[strlen(s)];
[551]308 if (*ArcTempRoot) {
[189]309 strcat(s, ArcTempRoot);
310 strcat(s, "*");
[2]311 search_handle = HDIR_CREATE;
312 num_matches = 1L;
[189]313 if (!DosFindFirst(s,
314 &search_handle,
315 FILE_NORMAL | FILE_DIRECTORY |
316 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
317 FILE_ARCHIVED,
[551]318 &f, sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
319 do {
[189]320 strcpy(enddir, f.achName);
[551]321 if (f.attrFile & FILE_DIRECTORY) {
[189]322 wipeallf("%s\\*", s);
323 DosDeleteDir(s);
324 }
325 else
326 unlinkf("%s", s);
327 }
328 while (!DosFindNext(search_handle,
[551]329 &f, sizeof(FILEFINDBUF3), &num_matches));
[2]330 DosFindClose(search_handle);
331 }
332 }
333
334 save_dir(s);
[189]335 if (s[strlen(s) - 1] != '\\')
336 strcat(s, "\\");
[2]337 enddir = &s[strlen(s)];
[189]338 strcat(s, LISTTEMPROOT);
339 strcat(s, "???");
[2]340 search_handle = HDIR_CREATE;
341 num_matches = 1L;
[189]342 if (!DosFindFirst(s,
343 &search_handle,
344 FILE_NORMAL | FILE_DIRECTORY |
345 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
346 FILE_ARCHIVED,
[551]347 &f, sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
348 do {
349 if (!(f.attrFile & FILE_DIRECTORY)) {
[189]350 strcpy(enddir, f.achName);
351 unlinkf("%s", s);
[2]352 }
[189]353 }
354 while (!DosFindNext(search_handle,
[551]355 &f, sizeof(FILEFINDBUF3), &num_matches));
[2]356 DosFindClose(search_handle);
357 }
358
359 DosForceDelete("$FM2PLAY.$$$");
360
361 EndNote();
362
[189]363 if (FM3ModHandle)
[2]364 DosFreeModule(FM3ModHandle);
365
[551]366 DosExitList(EXLST_REMOVE, DeInitFM3DLL);
[2]367}
368
[189]369BOOL InitFM3DLL(HAB hab, int argc, char **argv)
370{
[2]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;
[201]377 APIRET rc;
378 APIRET rcl = 1;
379 APIRET rcq = 1;
[551]380 PFN pfnResVersion = (PFN) NULL;
[201]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;
[2]388
[551]389 if (!StringsLoaded()) {
[2]390 saymsg(MB_ENTER,
[189]391 HWND_DESKTOP,
392 "Error",
393 "FM3RES.STR isn't in right format, at least "
394 "for this version of FM/2.");
[2]395 return FALSE;
396 }
397
[201]398 strcpy(dllfile, "FM3RES");
399 env = getenv("FM3INI");
[551]400 if (env) {
[201]401 FILESTATUS3 fsa;
402 APIRET rc;
[2]403
[201]404 DosError(FERR_DISABLEHARDERR);
[551]405 rc = DosQueryPathInfo(env, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
406 if (!rc) {
407 if (fsa.attrFile & FILE_DIRECTORY) {
[201]408 strcpy(dllfile, env);
409 if (dllfile[strlen(dllfile) - 1] != '\\')
410 strcat(dllfile, "\\");
411 strcat(dllfile, "FM3RES");
412 DosError(FERR_DISABLEHARDERR);
[551]413 if (DosQueryPathInfo(dllfile, FIL_STANDARD, &fsa, sizeof(fsa)))
[201]414 strcpy(dllfile, "FM3RES");
[2]415 }
416 }
[201]417 }
[551]418 rcl = DosLoadModule(NULL, 0, dllfile, &FM3ModHandle);
419 if (rcl) {
[339]420 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
421 HWND_DESKTOP,
[551]422 GetPString(IDS_ERRORTEXT), GetPString(IDS_FM3RESERROR1TEXT));
[339]423 return FALSE;
424 }
425 else {
426 rc = DosExitList(EXLST_ADD, DeInitFM3DLL);
[551]427 if (rc) {
[339]428 Dos_Error(MB_ENTER,
[551]429 rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosExitList failed");
[339]430 }
[551]431 rcq = DosQueryProcAddr(FM3ModHandle, 1, "ResVersion", &pfnResVersion);
[201]432 if (!rcq)
433 ret = pfnResVersion(&RVMajor, &RVMinor);
434 }
[339]435
[551]436 if (RVMajor < VERMAJOR || (RVMajor == VERMAJOR && RVMinor < VERMINOR)) {
[201]437 saymsg(MB_ENTER,
438 HWND_DESKTOP,
439 GetPString(IDS_ERRORTEXT),
440 GetPString(IDS_FM3RESERROR2TEXT),
441 !rcq ?
[551]442 GetPString(IDS_FM3RESERROR3TEXT) :
443 !rcl ?
444 GetPString(IDS_FM3RESERROR4TEXT) :
445 GetPString(IDS_FM3RESERROR5TEXT), RVMajor, RVMinor, rcl, rcq, ret);
[201]446 return FALSE;
[2]447 }
448
[189]449 ArgDriveFlags(argc, argv);
[2]450 FillInDriveFlags(NULL);
451
[627]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
[189]454 CHAR curpath[CCHMAXPATH + 8], *env;
[2]455 FILESTATUS3 fs3;
456
457 save_dir2(curpath);
[189]458 strcat(curpath, "\\UTILS");
459 if (!DosQueryPathInfo(curpath,
460 FIL_STANDARD,
461 &fs3,
[551]462 sizeof(fs3)) && (fs3.attrFile & FILE_DIRECTORY)) {
[2]463 env = getenv("PATH");
[551]464 if (env) {
[189]465 if (!stristr(curpath, env))
466 fAddUtils = TRUE;
[2]467 }
468 }
[627]469 } */
[189]470 if (!*profile)
471 strcpy(profile, "FM3.INI");
[2]472 mypid = getpid();
473 /* give default appname if none set by caller */
[189]474 if (!*appname)
475 strcpy(appname, FM3Str);
[2]476 /* save appname; may be reset below */
[189]477 strcpy(realappname, appname);
478 if (!strcmp(appname, FM3Str))
[2]479 DosSetMaxFH(100L);
[189]480 else if (!strcmp(appname, "VDir") ||
481 !strcmp(appname, "VTree") ||
482 !strcmp(appname, "VCollect") ||
[551]483 !strcmp(appname, "SEEALL") || !strcmp(appname, "FM/4"))
[2]484 DosSetMaxFH(60L);
485 else
486 DosSetMaxFH(40L);
487
[189]488 if (DosQuerySysInfo(QSV_VERSION_MAJOR,
489 QSV_VERSION_MINOR,
[551]490 (PVOID) OS2ver, (ULONG) sizeof(OS2ver))) {
[2]491 OS2ver[0] = 2;
492 OS2ver[1] = 1;
493 }
494
495 /* set up default root names for temp archive goodies */
[189]496 if (!fAmAV2)
497 strcpy(ArcTempRoot, "$FM$ARC$");
[2]498 else
[189]499 strcpy(ArcTempRoot, "$AV$ARC$");
[2]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 */
[551]507 if (_beginthread(HeapThread, NULL, 32768, NULL) == -1) {
508 Runtime_Error(pszSrcFile, __LINE__,
509 GetPString(IDS_COULDNTSTARTTHREADTEXT));
[339]510 return FALSE;
511 }
[189]512 /* timer messages are sent from a separate thread -- start it */
[339]513 if (!StartTimer())
[2]514 return FALSE;
515
[339]516 /* are we the workplace shell? */
[201]517 env = getenv("WORKPLACE__PROCESS");
518 if (!env || stricmp(env, "NO"))
519 fWorkPlace = TRUE;
[2]520
[189]521 if ((!strchr(profile, '\\') && !strchr(profile, ':')) ||
[551]522 !(fmprof = PrfOpenProfile((HAB) 0, profile))) {
[2]523 /* figure out where to put INI file... */
[189]524 CHAR *env, inipath[CCHMAXPATH];
[2]525
526 DosError(FERR_DISABLEHARDERR);
527 save_dir2(HomePath);
528 DosError(FERR_DISABLEHARDERR);
[189]529 memset(driveserial, -1, sizeof(driveserial));
[2]530 *inipath = 0;
531 env = getenv("FM3INI");
[551]532 if (env) {
[189]533 strcpy(inipath, env);
[2]534 DosError(FERR_DISABLEHARDERR);
[551]535 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
536 if (!rc) {
537 if (fsa.attrFile & FILE_DIRECTORY) {
[189]538 if (inipath[strlen(inipath) - 1] != '\\')
539 strcat(inipath, "\\");
540 strcat(inipath, profile);
541 }
[2]542 }
543 }
[551]544 if (!env) {
[2]545 env = searchpath(profile);
[189]546 if (!env)
547 env = profile;
548 strcpy(inipath, env);
[2]549 }
[201]550
[2]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 */
[201]553 if (!*inipath)
554 strcpy(inipath, profile);
555 DosError(FERR_DISABLEHARDERR);
[551]556 if (!DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa))) {
[201]557 fIniExisted = TRUE;
[551]558 if (fsa.attrFile & (FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM)) {
[201]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),
[551]565 GetPString(IDS_INIREADONLYTEXT), inipath);
[2]566 }
567 }
[201]568
[189]569 fmprof = PrfOpenProfile((HAB) 0, inipath);
[551]570 if (!fmprof) {
[189]571 strcpy(inipath, "FM3.INI");
572 fmprof = PrfOpenProfile((HAB) 0, inipath);
[2]573 }
[201]574
[551]575 if (!fmprof) {
576 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
577 "PrfOpenProfile failed");
[2]578 return FALSE;
579 }
580 }
581
582 FindSwapperDat();
583
[201]584 size = sizeof(BOOL);
585 PrfQueryProfileData(fmprof,
586 FM3Str,
[551]587 "SeparateParms", (PVOID) & fSeparateParms, &size);
[201]588 if (!fSeparateParms)
589 strcpy(appname, FM3Str);
[2]590
591 /* start help */
[189]592 memset(&hini, 0, sizeof(HELPINIT));
[2]593 hini.cb = sizeof(HELPINIT);
594 hini.ulReturnCode = 0L;
595 hini.pszTutorialName = NULL;
[189]596 hini.phtHelpTable = (PHELPTABLE) MAKELONG(ID_HELPTABLE, 0xffff);
597 hini.hmodAccelActionBarModule = (HMODULE) 0;
[2]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";
[189]603 hwndHelp = WinCreateHelpInstance(hab, &hini);
[551]604 if (!hwndHelp) {
[201]605 static CHAR helppath[CCHMAXPATH]; // fixme to be local?
[2]606
607 env = getenv("FM3INI");
[551]608 if (env) {
[2]609 FILESTATUS3 fsa;
[189]610 APIRET rc;
[2]611
[189]612 strcpy(helppath, env);
[2]613 DosError(FERR_DISABLEHARDERR);
[551]614 rc =
615 DosQueryPathInfo(helppath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
616 if (!rc) {
617 if (fsa.attrFile & FILE_DIRECTORY) {
[189]618 if (helppath[strlen(helppath) - 1] != '\\')
619 strcat(helppath, "\\");
620 strcat(helppath, "FM3.HLP");
621 hini.pszHelpLibraryName = helppath;
622 hwndHelp = WinCreateHelpInstance(hab, &hini);
623 }
[2]624 }
625 }
626 }
[551]627 if (!hwndHelp) {
[2]628 saymsg(MB_ENTER | MB_ICONEXCLAMATION,
[189]629 HWND_DESKTOP,
630 GetPString(IDS_FM2TROUBLETEXT),
631 GetPString(IDS_CANTLOADHELPTEXT),
632 GetPString(IDS_NOHELPACCEPTTEXT));
[2]633 }
634
635 /* a couple of default window procs so we don't have to look them up later */
[189]636 if (WinQueryClassInfo(hab, WC_CONTAINER, &clinfo))
[2]637 PFNWPCnr = clinfo.pfnWindowProc;
[179]638 // saymsg(MB_ENTER,HWND_DESKTOP,"Container flags:","%08lx",clinfo.flClassStyle);
[189]639 if (WinQueryClassInfo(hab, WC_FRAME, &clinfo))
[2]640 PFNWPFrame = clinfo.pfnWindowProc;
[179]641 // saymsg(MB_ENTER,HWND_DESKTOP,"Frame flags:","%08lx",clinfo.flClassStyle);
[189]642 if (WinQueryClassInfo(hab, WC_BUTTON, &clinfo))
[2]643 PFNWPButton = clinfo.pfnWindowProc;
[179]644 // saymsg(MB_ENTER,HWND_DESKTOP,"Button flags:","%08lx",clinfo.flClassStyle);
[189]645 if (WinQueryClassInfo(hab, WC_STATIC, &clinfo))
[2]646 PFNWPStatic = clinfo.pfnWindowProc;
[179]647 // saymsg(MB_ENTER,HWND_DESKTOP,"Static flags:","%08lx",clinfo.flClassStyle);
[189]648 if (WinQueryClassInfo(hab, WC_MLE, &clinfo))
[2]649 PFNWPMLE = clinfo.pfnWindowProc;
[179]650 // saymsg(MB_ENTER,HWND_DESKTOP,"MLE flags:","%08lx",clinfo.flClassStyle);
[551]651 if (!PFNWPCnr || !PFNWPFrame || !PFNWPButton || !PFNWPStatic || !PFNWPMLE) {
[339]652 Runtime_Error(pszSrcFile, __LINE__, "WinQueryClassInfo");
[2]653 return FALSE;
654 }
655
656 /* register window classes we use */
657 WinRegisterClass(hab,
[593]658 WC_MAINWND,
[189]659 MainWndProc,
[551]660 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 8);
[2]661 WinRegisterClass(hab,
[593]662 WC_MAINWND2,
[189]663 MainWndProc2,
[551]664 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 4);
[2]665 WinRegisterClass(hab,
[593]666 WC_TREECONTAINER,
[189]667 TreeClientWndProc,
[551]668 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]669 WinRegisterClass(hab,
[593]670 WC_DIRCONTAINER,
[189]671 DirClientWndProc,
[551]672 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]673 WinRegisterClass(hab,
[593]674 WC_COLLECTOR,
[189]675 CollectorClientWndProc,
[551]676 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]677 WinRegisterClass(hab,
[593]678 WC_ARCCONTAINER,
[189]679 ArcClientWndProc,
[551]680 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]681 WinRegisterClass(hab,
[593]682 WC_MLEEDITOR,
[189]683 MLEEditorProc,
[551]684 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]685 WinRegisterClass(hab,
[593]686 WC_INIEDITOR,
[189]687 IniProc,
[551]688 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]689 WinRegisterClass(hab,
[593]690 WC_TOOLBACK,
[551]691 ToolBackProc, CS_SIZEREDRAW, sizeof(PVOID));
[2]692 WinRegisterClass(hab,
[593]693 WC_DRIVEBACK,
[189]694 DriveBackProc,
695 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
696 sizeof(PVOID));
[2]697 WinRegisterClass(hab,
[593]698 WC_SEEALL,
[189]699 SeeAllWndProc,
[551]700 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
[2]701 WinRegisterClass(hab,
[593]702 WC_NEWVIEW,
[189]703 ViewWndProc,
[551]704 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
[2]705 WinRegisterClass(hab,
[593]706 WC_TOOLBUTTONS,
[189]707 ChildButtonProc,
708 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
709 sizeof(PVOID));
[2]710 WinRegisterClass(hab,
[593]711 WC_DRIVEBUTTONS,
[189]712 DriveProc,
713 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
714 sizeof(PVOID));
[2]715 WinRegisterClass(hab,
[593]716 WC_BUBBLE,
[189]717 BubbleProc,
718 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
719 sizeof(ULONG) * 2);
[2]720 WinRegisterClass(hab,
[593]721 WC_STATUS,
[189]722 StatusProc,
723 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
724 sizeof(ULONG));
[2]725 WinRegisterClass(hab,
[593]726 WC_DIRSTATUS,
[189]727 DirTextProc,
728 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
729 sizeof(ULONG));
[2]730 WinRegisterClass(hab,
[593]731 WC_TREESTATUS,
[189]732 TreeStatProc,
733 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
734 sizeof(ULONG));
[2]735 WinRegisterClass(hab,
[593]736 WC_ARCSTATUS,
[189]737 ArcTextProc,
738 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
739 sizeof(ULONG));
[2]740 WinRegisterClass(hab,
[593]741 WC_COLSTATUS,
[189]742 CollectorTextProc,
743 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
744 sizeof(ULONG));
[2]745 WinRegisterClass(hab,
[593]746 WC_SEESTATUS,
[189]747 SeeStatusProc,
748 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
749 sizeof(ULONG));
[2]750 WinRegisterClass(hab,
[593]751 WC_VIEWSTATUS,
[189]752 ViewStatusProc,
753 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
754 sizeof(ULONG));
[2]755 WinRegisterClass(hab,
[593]756 WC_ERRORWND,
[189]757 NotifyWndProc,
758 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
759 sizeof(PVOID));
[2]760 WinRegisterClass(hab,
[593]761 WC_MINITIME,
[189]762 MiniTimeProc,
763 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
764 sizeof(PVOID) * 2);
[2]765 WinRegisterClass(hab,
[593]766 WC_DATABAR,
[551]767 DataProc, CS_SIZEREDRAW, sizeof(PVOID));
[2]768 WinRegisterClass(hab,
[593]769 WC_TREEOPENBUTTON,
[189]770 OpenButtonProc,
771 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
772 sizeof(PVOID));
[2]773 WinRegisterClass(hab,
[593]774 WC_AUTOVIEW,
[189]775 AutoViewProc,
776 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
777 sizeof(PVOID));
[2]778 WinRegisterClass(hab,
[593]779 WC_LED,
[189]780 LEDProc,
781 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
782 sizeof(PVOID));
[2]783
784 /*
[201]785 * set some defaults (note: everything else automatically initialized
[2]786 * to 0)
787 */
788 detailssize = detailsea = detailslwdate = detailslwtime = detailsattr =
[189]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;
[2]797 ulCnrType = CCS_EXTENDSEL;
798 FilesToGet = 128L;
799 AutoviewHeight = 48L;
[189]800 strcpy(printer, "PRN");
[2]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
[201]811 // load preferences from profile (INI) file
812 size = sizeof(BOOL);
813 PrfQueryProfileData(fmprof,
[551]814 appname, "ShowTarget", (PVOID) & fShowTarget, &size);
[201]815 size = sizeof(BOOL);
[551]816 PrfQueryProfileData(fmprof, appname, "CheckMM", (PVOID) & fCheckMM, &size);
[201]817 size = sizeof(BOOL);
818 PrfQueryProfileData(fmprof,
819 appname,
[551]820 "ChangeTarget", (PVOID) & fChangeTarget, &size);
[201]821 size = sizeof(BOOL);
822 PrfQueryProfileData(fmprof,
823 appname,
[551]824 "ConfirmTarget", (PVOID) & fConfirmTarget, &size);
[201]825 size = sizeof(BOOL);
826 PrfQueryProfileData(fmprof,
827 FM3Str,
[551]828 "CustomFileDlg", (PVOID) & fCustomFileDlg, &size);
[201]829 size = sizeof(BOOL);
830 PrfQueryProfileData(fmprof,
[551]831 FM3Str, "SaveMiniCmds", (PVOID) & fSaveMiniCmds, &size);
[201]832 size = sizeof(BOOL);
833 PrfQueryProfileData(fmprof,
[551]834 appname, "SaveBigCmds", (PVOID) & fSaveBigCmds, &size);
[201]835 size = sizeof(BOOL);
836 PrfQueryProfileData(fmprof,
[551]837 appname, "NoFoldMenu", (PVOID) & fNoFoldMenu, &size);
[201]838 size = sizeof(BOOL);
839 PrfQueryProfileData(fmprof,
[551]840 FM3Str, "ThreadNotes", (PVOID) & fThreadNotes, &size);
841 size = sizeof(BOOL);
842 PrfQueryProfileData(fmprof, FM3Str, "Prnpagenums", (PVOID) & prnpagenums,
[201]843 &size);
844 size = sizeof(BOOL);
845 PrfQueryProfileData(fmprof, FM3Str, "Prnalt", (PVOID) & prnalt, &size);
846 size = sizeof(BOOL);
[551]847 PrfQueryProfileData(fmprof, FM3Str, "Prnformat", (PVOID) & prnformat,
848 &size);
[201]849 size = sizeof(BOOL);
850 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedbefore",
851 (PVOID) & prnformfeedbefore, &size);
852 size = sizeof(BOOL);
853 PrfQueryProfileData(fmprof,
854 FM3Str,
[551]855 "Prnformfeedafter", (PVOID) & prnformfeedafter, &size);
[201]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);
[551]862 PrfQueryProfileData(fmprof, FM3Str, "Prnlength", (PVOID) & prnlength,
863 &size);
[201]864 size = sizeof(ULONG);
[551]865 PrfQueryProfileData(fmprof, FM3Str, "Prntmargin", (PVOID) & prntmargin,
866 &size);
[201]867 size = sizeof(ULONG);
[551]868 PrfQueryProfileData(fmprof, FM3Str, "Prnbmargin", (PVOID) & prnbmargin,
869 &size);
[201]870 size = sizeof(ULONG);
[551]871 PrfQueryProfileData(fmprof, FM3Str, "Prnlmargin", (PVOID) & prnlmargin,
872 &size);
[201]873 size = sizeof(ULONG);
[551]874 PrfQueryProfileData(fmprof, FM3Str, "Prnrmargin", (PVOID) & prnrmargin,
875 &size);
[201]876 size = sizeof(ULONG);
[551]877 PrfQueryProfileData(fmprof, FM3Str, "Prnspacing", (PVOID) & prnspacing,
878 &size);
[201]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);
[551]901 PrfQueryProfileData(fmprof, FM3Str, "LookInDir", (PVOID) & fLookInDir,
902 &size);
903 PrfQueryProfileString(fmprof, appname, "DefArc", NULL, szDefArc,
904 sizeof(szDefArc));
[201]905 size = sizeof(ULONG);
906 PrfQueryProfileData(fmprof, FM3Str, "AutoviewHeight",
907 (PVOID) & AutoviewHeight, &size);
908 size = sizeof(BOOL);
[551]909 PrfQueryProfileData(fmprof, FM3Str, "KeepCmdLine", (PVOID) & fKeepCmdLine,
910 &size);
911 if (strcmp(realappname, "FM/4")) {
[2]912 size = sizeof(BOOL);
913 PrfQueryProfileData(fmprof,
[551]914 FM3Str, "MoreButtons", (PVOID) & fMoreButtons, &size);
[2]915 size = sizeof(BOOL);
916 PrfQueryProfileData(fmprof,
[551]917 FM3Str, "Drivebar", (PVOID) & fDrivebar, &size);
[201]918 }
919 else
920 fDrivebar = fMoreButtons = TRUE;
921 size = sizeof(BOOL);
922 PrfQueryProfileData(fmprof,
[551]923 appname, "NoSearch", (PVOID) & fNoSearch, &size);
[201]924 size = sizeof(BOOL);
925 PrfQueryProfileData(fmprof,
[551]926 appname, "GuessType", (PVOID) & fGuessType, &size);
[201]927 size = sizeof(BOOL);
928 PrfQueryProfileData(fmprof,
[551]929 appname, "ViewChild", (PVOID) & fViewChild, &size);
[201]930 size = sizeof(BOOL);
[551]931 PrfQueryProfileData(fmprof, appname, "ShowEnv", (PVOID) & fShowEnv, &size);
[201]932 size = sizeof(BOOL);
933 PrfQueryProfileData(fmprof,
[551]934 appname, "LeaveTree", (PVOID) & fLeaveTree, &size);
[201]935 size = sizeof(BOOL);
936 PrfQueryProfileData(fmprof, FM3Str, "Comments", (PVOID) & fComments, &size);
937 size = sizeof(ULONG);
[551]938 PrfQueryProfileData(fmprof, appname, "WS_ANIMATE", (PVOID) & fwsAnimate,
939 &size);
[201]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);
[551]947 PrfQueryProfileData(fmprof, FM3Str, "ToolbarHelp", (PVOID) & fToolbarHelp,
948 &size);
[201]949 size = sizeof(BOOL);
[551]950 PrfQueryProfileData(fmprof, FM3Str, "OtherHelp", (PVOID) & fOtherHelp,
951 &size);
[201]952 size = sizeof(BOOL);
[551]953 PrfQueryProfileData(fmprof, FM3Str, "DrivebarHelp", (PVOID) & fDrivebarHelp,
954 &size);
[201]955 size = sizeof(BOOL);
956 PrfQueryProfileData(fmprof,
[551]957 appname, "AutoAddDirs", (PVOID) & fAutoAddDirs, &size);
[201]958 size = sizeof(BOOL);
959 PrfQueryProfileData(fmprof,
960 appname,
[551]961 "AutoAddAllDirs", (PVOID) & fAutoAddAllDirs, &size);
[201]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);
[551]989 PrfQueryProfileData(fmprof, appname, "DataToFore", (PVOID) & fDataToFore,
990 &size);
[201]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);
[551]998 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", (PVOID) & fSplitStatus,
999 &size);
[201]1000 size = sizeof(BOOL);
1001 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract",
1002 (PVOID) & fFolderAfterExtract, &size);
1003 size = sizeof(BOOL);
[551]1004 PrfQueryProfileData(fmprof, FM3Str, "DullDatabar", (PVOID) & fDullMin,
1005 &size);
[201]1006 size = sizeof(BOOL);
1007 PrfQueryProfileData(fmprof, appname, "BlueLED", (PVOID) & fBlueLED, &size);
1008 size = sizeof(BOOL);
[551]1009 PrfQueryProfileData(fmprof, appname, "ConfirmDelete",
1010 (PVOID) & fConfirmDelete, &size);
[201]1011 size = sizeof(BOOL);
[551]1012 PrfQueryProfileData(fmprof, FM3Str, "SaveState", (PVOID) & fSaveState,
1013 &size);
[201]1014 size = sizeof(BOOL);
[551]1015 PrfQueryProfileData(fmprof, appname, "SyncUpdates", (PVOID) & fSyncUpdates,
1016 &size);
[201]1017 size = sizeof(BOOL);
[551]1018 PrfQueryProfileData(fmprof, appname, "LoadSubject", (PVOID) & fLoadSubject,
1019 &size);
[201]1020 size = sizeof(BOOL);
[551]1021 PrfQueryProfileData(fmprof, appname, "UnHilite", (PVOID) & fUnHilite,
[201]1022 &size);
1023 size = sizeof(BOOL);
[551]1024 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards",
1025 (PVOID) & fTileBackwards, &size);
[201]1026 size = sizeof(BOOL);
[551]1027 PrfQueryProfileData(fmprof, appname, "LoadLongname",
1028 (PVOID) & fLoadLongnames, &size);
1029 size = sizeof(BOOL);
1030 PrfQueryProfileData(fmprof, appname, "VerifyWrites", (PVOID) & fVerify,
1031 &size);
[201]1032 DosSetVerify(fVerify);
1033 size = sizeof(BOOL);
[551]1034 PrfQueryProfileData(fmprof, appname, "DontMoveMouse",
1035 (PVOID) & fDontMoveMouse, &size);
[201]1036 size = sizeof(BOOL);
[551]1037 PrfQueryProfileData(fmprof, appname, "NoIconsFiles",
1038 (PVOID) & fNoIconsFiles, &size);
[201]1039 size = sizeof(BOOL);
[551]1040 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", (PVOID) & fNoIconsDirs,
1041 &size);
[201]1042 size = sizeof(BOOL);
[551]1043 PrfQueryProfileData(fmprof, appname, "ForceUpper", (PVOID) & fForceUpper,
1044 &size);
[201]1045 size = sizeof(BOOL);
[551]1046 PrfQueryProfileData(fmprof, appname, "ForceLower", (PVOID) & fForceLower,
1047 &size);
[201]1048 size = sizeof(BOOL);
[551]1049 PrfQueryProfileData(fmprof, FM3Str, "TextTools", (PVOID) & fTextTools,
1050 &size);
[201]1051 size = sizeof(BOOL);
[551]1052 PrfQueryProfileData(fmprof, FM3Str, "ToolTitles", (PVOID) & fToolTitles,
1053 &size);
[201]1054 size = sizeof(BOOL);
[551]1055 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", (PVOID) & fDCOpens,
1056 &size);
[201]1057 size = sizeof(BOOL);
[551]1058 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon",
1059 (PVOID) & fLinkSetsIcon, &size);
[201]1060 size = sizeof(INT);
1061 PrfQueryProfileData(fmprof, appname, "Sort", (PVOID) & sortFlags, &size);
1062 size = sizeof(INT);
[551]1063 PrfQueryProfileData(fmprof, appname, "TreeSort", (PVOID) & TreesortFlags,
1064 &size);
[201]1065 size = sizeof(INT);
1066 PrfQueryProfileData(fmprof,
1067 appname,
[551]1068 "CollectorSort", (PVOID) & CollectorsortFlags, &size);
[201]1069 size = sizeof(targetdir);
[551]1070 PrfQueryProfileData(fmprof, appname, "Targetdir", (PVOID) targetdir, &size);
[201]1071 if (!IsValidDir(targetdir))
1072 *targetdir = 0;
1073 size = sizeof(extractpath);
1074 PrfQueryProfileData(fmprof,
[551]1075 appname, "ExtractPath", (PVOID) extractpath, &size);
[201]1076 if (!IsValidDir(extractpath))
1077 *extractpath = 0;
1078 size = sizeof(printer);
1079 PrfQueryProfileData(fmprof, appname, "Printer", (PVOID) printer, &size);
1080 size = sizeof(dircompare);
[551]1081 PrfQueryProfileData(fmprof, appname, "DirCompare", (PVOID) dircompare,
1082 &size);
[201]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);
[551]1104 PrfQueryProfileData(fmprof, FM3Str, "LastToolBox", (PVOID) lasttoolbox,
1105 &size);
[201]1106 size = sizeof(BOOL);
[551]1107 PrfQueryProfileData(fmprof, appname, "FollowTree", (PVOID) & fFollowTree,
1108 &size);
[201]1109 size = sizeof(BOOL);
[551]1110 PrfQueryProfileData(fmprof, appname, "StartMaximized",
1111 (PVOID) & fStartMaximized, &size);
1112 if (!fStartMaximized) {
[2]1113 size = sizeof(BOOL);
[551]1114 PrfQueryProfileData(fmprof, appname, "StartMinimized",
1115 (PVOID) & fStartMinimized, &size);
[2]1116 }
[201]1117 size = sizeof(BOOL);
[551]1118 PrfQueryProfileData(fmprof, appname, "DefaultCopy", (PVOID) & fCopyDefault,
1119 &size);
[201]1120 size = sizeof(BOOL);
[551]1121 PrfQueryProfileData(fmprof, appname, "IdleCopy", (PVOID) & fRealIdle,
1122 &size);
[201]1123 size = sizeof(BOOL);
1124 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible",
1125 (PVOID) & fArcStuffVisible, &size);
1126 size = sizeof(BOOL);
[551]1127 PrfQueryProfileData(fmprof, FM3Str, "NoTreeGap", (PVOID) & fNoTreeGap,
[201]1128 &size);
1129 size = sizeof(BOOL);
[551]1130 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS",
1131 (PVOID) & fVTreeOpensWPS, &size);
[201]1132 size = sizeof(BOOL);
[551]1133 PrfQueryProfileData(fmprof, appname, "RemoteBug", (PVOID) & fRemoteBug,
[201]1134 &size);
1135 size = sizeof(BOOL);
[551]1136 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg",
1137 (PVOID) & fDragndropDlg, &size);
1138 size = sizeof(BOOL);
[201]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);
[551]1145 PrfQueryProfileData(fmprof, appname, "QuickArcFind",
1146 (PVOID) & fQuickArcFind, &size);
[201]1147 size = sizeof(BOOL);
[551]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,
[201]1155 &size);
1156 size = sizeof(ULONG);
[551]1157 PrfQueryProfileData(fmprof, appname, "FilesToGet", (PVOID) & FilesToGet,
[201]1158 &size);
1159 size = sizeof(BOOL);
1160 PrfQueryProfileData(fmprof, FM3Str, "AutoView", (PVOID) & fAutoView, &size);
1161 size = sizeof(BOOL);
[551]1162 PrfQueryProfileData(fmprof, FM3Str, "FM2Deletes", (PVOID) & fFM2Deletes,
1163 &size);
[2]1164
1165 /* load pointers and icons we use */
[189]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);
[552]1180 hptrReadonly = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_READONLY_ICON);
[189]1181 hptrLast = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, LASTITEM_ICON);
1182 hptrRemote = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOTE_ICON);
[552]1183 hptrVirtual = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, VIRTUAL_ICON);
1184 hptrRamdisk = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, RAMDISK_ICON);
[189]1185 if (!fNoDead)
1186 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER_ICON);
[2]1187 else
[189]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);
[2]1193
[201]1194 // set up color array used by seeall.c and newview.c color dialog
1195
[189]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;
[2]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
[189]1216HWND StartFM3(HAB hab, INT argc, CHAR ** argv)
1217{
[201]1218 HWND hwndFrame;
1219 HWND hwndClient;
1220 UINT x;
[189]1221 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
[551]1222 FCF_SIZEBORDER | FCF_MINMAX |
1223 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
[2]1224
[551]1225 for (x = 1; x < argc; x++) {
[201]1226 if (*argv[x] == '~' && !argv[x][1])
1227 fReminimize = TRUE;
1228 if (*argv[x] == '+' && !argv[x][1])
1229 fLogFile = TRUE;
[551]1230 if (*argv[x] == '-') {
[201]1231 if (!argv[x][1])
1232 fNoSaveState = TRUE;
1233 else
1234 strcpy(profile, &argv[x][1]);
[2]1235 }
1236 }
1237
1238 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
[189]1239 WS_VISIBLE,
1240 &FrameFlags,
[593]1241 WC_MAINWND,
[189]1242 NULL,
1243 WS_VISIBLE | WS_ANIMATE,
[551]1244 FM3ModHandle, MAIN_FRAME, &hwndClient);
1245 if (hwndFrame) {
1246 WinSetWindowUShort(hwndFrame, QWS_ID, MAIN_FRAME);
1247 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos", hwndFrame)) {
[2]1248
1249 ULONG fl = SWP_MOVE | SWP_SIZE;
1250 RECTL rcl;
[189]1251 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1252 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
[2]1253
[551]1254 WinQueryWindowRect(HWND_DESKTOP, &rcl);
[2]1255 rcl.yBottom += icz;
1256 rcl.yTop -= bsz;
1257 rcl.xLeft += bsz;
1258 rcl.xRight -= bsz;
1259 WinSetWindowPos(hwndFrame,
[189]1260 HWND_TOP,
1261 rcl.xLeft,
1262 rcl.yBottom,
[551]1263 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
[2]1264 }
[189]1265 if (fLogFile)
[551]1266 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
[189]1267 if (hwndHelp)
[551]1268 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1269 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
[2]1270 }
1271 return hwndFrame;
1272}
[32]1273
[189]1274int CheckVersion(int vermajor, int verminor)
1275{
[179]1276 int ok = 0;
[32]1277
[179]1278 // fixme to do useful check - was missing in base source
1279
[32]1280#if 0
[551]1281 if (vermajor && verminor) {
[32]1282 *vermajor = VERMAJOR;
1283 *verminor = VERMINOR;
[179]1284 ok = 1;
[32]1285 }
1286#endif
[189]1287
[179]1288 ok = 1;
[32]1289
[179]1290 return ok;
[32]1291}
Note: See TracBrowser for help on using the repository browser.