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
RevLine 
[32]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
[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 != '\"')
[689]124 *pp += 1;
[189]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));
[689]257 RGBGREY.bRed = RGBGREY.bGreen = RGBGREY.bBlue = (BYTE)204;
[189]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
[689]302# ifdef __IBMC__
[2]303 _fcloseall();
[689]304# else // __WATCOMC__
305 fcloseall();
306# endif
[2]307
308 save_dir(s);
[189]309 if (s[strlen(s) - 1] != '\\')
310 strcat(s, "\\");
[2]311 enddir = &s[strlen(s)];
[551]312 if (*ArcTempRoot) {
[189]313 strcat(s, ArcTempRoot);
314 strcat(s, "*");
[2]315 search_handle = HDIR_CREATE;
316 num_matches = 1L;
[189]317 if (!DosFindFirst(s,
318 &search_handle,
319 FILE_NORMAL | FILE_DIRECTORY |
320 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
321 FILE_ARCHIVED,
[551]322 &f, sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
323 do {
[189]324 strcpy(enddir, f.achName);
[551]325 if (f.attrFile & FILE_DIRECTORY) {
[189]326 wipeallf("%s\\*", s);
327 DosDeleteDir(s);
328 }
329 else
330 unlinkf("%s", s);
331 }
332 while (!DosFindNext(search_handle,
[551]333 &f, sizeof(FILEFINDBUF3), &num_matches));
[2]334 DosFindClose(search_handle);
335 }
336 }
337
338 save_dir(s);
[189]339 if (s[strlen(s) - 1] != '\\')
340 strcat(s, "\\");
[2]341 enddir = &s[strlen(s)];
[189]342 strcat(s, LISTTEMPROOT);
343 strcat(s, "???");
[2]344 search_handle = HDIR_CREATE;
345 num_matches = 1L;
[189]346 if (!DosFindFirst(s,
347 &search_handle,
348 FILE_NORMAL | FILE_DIRECTORY |
349 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
350 FILE_ARCHIVED,
[551]351 &f, sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
352 do {
353 if (!(f.attrFile & FILE_DIRECTORY)) {
[189]354 strcpy(enddir, f.achName);
355 unlinkf("%s", s);
[2]356 }
[189]357 }
358 while (!DosFindNext(search_handle,
[551]359 &f, sizeof(FILEFINDBUF3), &num_matches));
[2]360 DosFindClose(search_handle);
361 }
362
363 DosForceDelete("$FM2PLAY.$$$");
364
365 EndNote();
366
[189]367 if (FM3ModHandle)
[2]368 DosFreeModule(FM3ModHandle);
369
[551]370 DosExitList(EXLST_REMOVE, DeInitFM3DLL);
[2]371}
372
[189]373BOOL InitFM3DLL(HAB hab, int argc, char **argv)
374{
[2]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;
[201]381 APIRET rc;
382 APIRET rcl = 1;
383 APIRET rcq = 1;
[551]384 PFN pfnResVersion = (PFN) NULL;
[201]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;
[2]392
[551]393 if (!StringsLoaded()) {
[2]394 saymsg(MB_ENTER,
[189]395 HWND_DESKTOP,
396 "Error",
397 "FM3RES.STR isn't in right format, at least "
398 "for this version of FM/2.");
[2]399 return FALSE;
400 }
401
[201]402 strcpy(dllfile, "FM3RES");
403 env = getenv("FM3INI");
[551]404 if (env) {
[201]405 FILESTATUS3 fsa;
406 APIRET rc;
[2]407
[201]408 DosError(FERR_DISABLEHARDERR);
[551]409 rc = DosQueryPathInfo(env, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
410 if (!rc) {
411 if (fsa.attrFile & FILE_DIRECTORY) {
[201]412 strcpy(dllfile, env);
413 if (dllfile[strlen(dllfile) - 1] != '\\')
414 strcat(dllfile, "\\");
415 strcat(dllfile, "FM3RES");
416 DosError(FERR_DISABLEHARDERR);
[551]417 if (DosQueryPathInfo(dllfile, FIL_STANDARD, &fsa, sizeof(fsa)))
[201]418 strcpy(dllfile, "FM3RES");
[2]419 }
420 }
[201]421 }
[551]422 rcl = DosLoadModule(NULL, 0, dllfile, &FM3ModHandle);
423 if (rcl) {
[339]424 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
425 HWND_DESKTOP,
[551]426 GetPString(IDS_ERRORTEXT), GetPString(IDS_FM3RESERROR1TEXT));
[339]427 return FALSE;
428 }
429 else {
430 rc = DosExitList(EXLST_ADD, DeInitFM3DLL);
[551]431 if (rc) {
[339]432 Dos_Error(MB_ENTER,
[551]433 rc, HWND_DESKTOP, pszSrcFile, __LINE__, "DosExitList failed");
[339]434 }
[551]435 rcq = DosQueryProcAddr(FM3ModHandle, 1, "ResVersion", &pfnResVersion);
[201]436 if (!rcq)
437 ret = pfnResVersion(&RVMajor, &RVMinor);
438 }
[339]439
[551]440 if (RVMajor < VERMAJOR || (RVMajor == VERMAJOR && RVMinor < VERMINOR)) {
[201]441 saymsg(MB_ENTER,
442 HWND_DESKTOP,
443 GetPString(IDS_ERRORTEXT),
444 GetPString(IDS_FM3RESERROR2TEXT),
445 !rcq ?
[551]446 GetPString(IDS_FM3RESERROR3TEXT) :
447 !rcl ?
448 GetPString(IDS_FM3RESERROR4TEXT) :
449 GetPString(IDS_FM3RESERROR5TEXT), RVMajor, RVMinor, rcl, rcq, ret);
[201]450 return FALSE;
[2]451 }
452
[189]453 ArgDriveFlags(argc, argv);
[2]454 FillInDriveFlags(NULL);
455
[189]456 if (!*profile)
457 strcpy(profile, "FM3.INI");
[2]458 mypid = getpid();
459 /* give default appname if none set by caller */
[189]460 if (!*appname)
461 strcpy(appname, FM3Str);
[2]462 /* save appname; may be reset below */
[189]463 strcpy(realappname, appname);
464 if (!strcmp(appname, FM3Str))
[2]465 DosSetMaxFH(100L);
[189]466 else if (!strcmp(appname, "VDir") ||
467 !strcmp(appname, "VTree") ||
468 !strcmp(appname, "VCollect") ||
[551]469 !strcmp(appname, "SEEALL") || !strcmp(appname, "FM/4"))
[2]470 DosSetMaxFH(60L);
471 else
472 DosSetMaxFH(40L);
473
[189]474 if (DosQuerySysInfo(QSV_VERSION_MAJOR,
475 QSV_VERSION_MINOR,
[551]476 (PVOID) OS2ver, (ULONG) sizeof(OS2ver))) {
[2]477 OS2ver[0] = 2;
478 OS2ver[1] = 1;
479 }
480
481 /* set up default root names for temp archive goodies */
[189]482 if (!fAmAV2)
483 strcpy(ArcTempRoot, "$FM$ARC$");
[2]484 else
[189]485 strcpy(ArcTempRoot, "$AV$ARC$");
[2]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 */
[551]493 if (_beginthread(HeapThread, NULL, 32768, NULL) == -1) {
494 Runtime_Error(pszSrcFile, __LINE__,
495 GetPString(IDS_COULDNTSTARTTHREADTEXT));
[339]496 return FALSE;
497 }
[189]498 /* timer messages are sent from a separate thread -- start it */
[339]499 if (!StartTimer())
[2]500 return FALSE;
501
[339]502 /* are we the workplace shell? */
[201]503 env = getenv("WORKPLACE__PROCESS");
504 if (!env || stricmp(env, "NO"))
505 fWorkPlace = TRUE;
[2]506
[189]507 if ((!strchr(profile, '\\') && !strchr(profile, ':')) ||
[551]508 !(fmprof = PrfOpenProfile((HAB) 0, profile))) {
[2]509 /* figure out where to put INI file... */
[189]510 CHAR *env, inipath[CCHMAXPATH];
[2]511
512 DosError(FERR_DISABLEHARDERR);
513 save_dir2(HomePath);
514 DosError(FERR_DISABLEHARDERR);
[189]515 memset(driveserial, -1, sizeof(driveserial));
[2]516 *inipath = 0;
517 env = getenv("FM3INI");
[551]518 if (env) {
[189]519 strcpy(inipath, env);
[2]520 DosError(FERR_DISABLEHARDERR);
[551]521 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
522 if (!rc) {
523 if (fsa.attrFile & FILE_DIRECTORY) {
[189]524 if (inipath[strlen(inipath) - 1] != '\\')
525 strcat(inipath, "\\");
526 strcat(inipath, profile);
527 }
[2]528 }
529 }
[551]530 if (!env) {
[2]531 env = searchpath(profile);
[189]532 if (!env)
533 env = profile;
534 strcpy(inipath, env);
[2]535 }
[201]536
[2]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 */
[201]539 if (!*inipath)
540 strcpy(inipath, profile);
541 DosError(FERR_DISABLEHARDERR);
[551]542 if (!DosQueryPathInfo(inipath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa))) {
[201]543 fIniExisted = TRUE;
[551]544 if (fsa.attrFile & (FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM)) {
[201]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]551 GetPString(IDS_INIREADONLYTEXT), inipath);
[2]552 }
553 }
[201]554
[189]555 fmprof = PrfOpenProfile((HAB) 0, inipath);
[551]556 if (!fmprof) {
[189]557 strcpy(inipath, "FM3.INI");
558 fmprof = PrfOpenProfile((HAB) 0, inipath);
[2]559 }
[201]560
[551]561 if (!fmprof) {
562 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
563 "PrfOpenProfile failed");
[2]564 return FALSE;
565 }
566 }
567
568 FindSwapperDat();
569
[201]570 size = sizeof(BOOL);
571 PrfQueryProfileData(fmprof,
572 FM3Str,
[551]573 "SeparateParms", (PVOID) & fSeparateParms, &size);
[201]574 if (!fSeparateParms)
575 strcpy(appname, FM3Str);
[2]576
577 /* start help */
[189]578 memset(&hini, 0, sizeof(HELPINIT));
[2]579 hini.cb = sizeof(HELPINIT);
580 hini.ulReturnCode = 0L;
581 hini.pszTutorialName = NULL;
[189]582 hini.phtHelpTable = (PHELPTABLE) MAKELONG(ID_HELPTABLE, 0xffff);
583 hini.hmodAccelActionBarModule = (HMODULE) 0;
[2]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";
[189]589 hwndHelp = WinCreateHelpInstance(hab, &hini);
[551]590 if (!hwndHelp) {
[201]591 static CHAR helppath[CCHMAXPATH]; // fixme to be local?
[2]592
593 env = getenv("FM3INI");
[551]594 if (env) {
[2]595 FILESTATUS3 fsa;
[189]596 APIRET rc;
[2]597
[189]598 strcpy(helppath, env);
[2]599 DosError(FERR_DISABLEHARDERR);
[551]600 rc =
601 DosQueryPathInfo(helppath, FIL_STANDARD, &fsa, (ULONG) sizeof(fsa));
602 if (!rc) {
603 if (fsa.attrFile & FILE_DIRECTORY) {
[189]604 if (helppath[strlen(helppath) - 1] != '\\')
605 strcat(helppath, "\\");
606 strcat(helppath, "FM3.HLP");
607 hini.pszHelpLibraryName = helppath;
608 hwndHelp = WinCreateHelpInstance(hab, &hini);
609 }
[2]610 }
611 }
612 }
[551]613 if (!hwndHelp) {
[2]614 saymsg(MB_ENTER | MB_ICONEXCLAMATION,
[189]615 HWND_DESKTOP,
616 GetPString(IDS_FM2TROUBLETEXT),
617 GetPString(IDS_CANTLOADHELPTEXT),
618 GetPString(IDS_NOHELPACCEPTTEXT));
[2]619 }
620
621 /* a couple of default window procs so we don't have to look them up later */
[189]622 if (WinQueryClassInfo(hab, WC_CONTAINER, &clinfo))
[2]623 PFNWPCnr = clinfo.pfnWindowProc;
[179]624 // saymsg(MB_ENTER,HWND_DESKTOP,"Container flags:","%08lx",clinfo.flClassStyle);
[189]625 if (WinQueryClassInfo(hab, WC_FRAME, &clinfo))
[2]626 PFNWPFrame = clinfo.pfnWindowProc;
[179]627 // saymsg(MB_ENTER,HWND_DESKTOP,"Frame flags:","%08lx",clinfo.flClassStyle);
[189]628 if (WinQueryClassInfo(hab, WC_BUTTON, &clinfo))
[2]629 PFNWPButton = clinfo.pfnWindowProc;
[179]630 // saymsg(MB_ENTER,HWND_DESKTOP,"Button flags:","%08lx",clinfo.flClassStyle);
[189]631 if (WinQueryClassInfo(hab, WC_STATIC, &clinfo))
[2]632 PFNWPStatic = clinfo.pfnWindowProc;
[179]633 // saymsg(MB_ENTER,HWND_DESKTOP,"Static flags:","%08lx",clinfo.flClassStyle);
[189]634 if (WinQueryClassInfo(hab, WC_MLE, &clinfo))
[2]635 PFNWPMLE = clinfo.pfnWindowProc;
[179]636 // saymsg(MB_ENTER,HWND_DESKTOP,"MLE flags:","%08lx",clinfo.flClassStyle);
[551]637 if (!PFNWPCnr || !PFNWPFrame || !PFNWPButton || !PFNWPStatic || !PFNWPMLE) {
[339]638 Runtime_Error(pszSrcFile, __LINE__, "WinQueryClassInfo");
[2]639 return FALSE;
640 }
641
642 /* register window classes we use */
643 WinRegisterClass(hab,
[593]644 WC_MAINWND,
[189]645 MainWndProc,
[551]646 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 8);
[2]647 WinRegisterClass(hab,
[593]648 WC_MAINWND2,
[189]649 MainWndProc2,
[551]650 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 4);
[2]651 WinRegisterClass(hab,
[593]652 WC_TREECONTAINER,
[189]653 TreeClientWndProc,
[551]654 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]655 WinRegisterClass(hab,
[593]656 WC_DIRCONTAINER,
[189]657 DirClientWndProc,
[551]658 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]659 WinRegisterClass(hab,
[593]660 WC_COLLECTOR,
[189]661 CollectorClientWndProc,
[551]662 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]663 WinRegisterClass(hab,
[593]664 WC_ARCCONTAINER,
[189]665 ArcClientWndProc,
[551]666 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]667 WinRegisterClass(hab,
[593]668 WC_MLEEDITOR,
[189]669 MLEEditorProc,
[551]670 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]671 WinRegisterClass(hab,
[593]672 WC_INIEDITOR,
[189]673 IniProc,
[551]674 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]675 WinRegisterClass(hab,
[593]676 WC_TOOLBACK,
[551]677 ToolBackProc, CS_SIZEREDRAW, sizeof(PVOID));
[2]678 WinRegisterClass(hab,
[593]679 WC_DRIVEBACK,
[189]680 DriveBackProc,
681 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
682 sizeof(PVOID));
[2]683 WinRegisterClass(hab,
[593]684 WC_SEEALL,
[189]685 SeeAllWndProc,
[551]686 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
[2]687 WinRegisterClass(hab,
[593]688 WC_NEWVIEW,
[189]689 ViewWndProc,
[551]690 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
[2]691 WinRegisterClass(hab,
[593]692 WC_TOOLBUTTONS,
[189]693 ChildButtonProc,
694 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
695 sizeof(PVOID));
[2]696 WinRegisterClass(hab,
[593]697 WC_DRIVEBUTTONS,
[189]698 DriveProc,
699 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
700 sizeof(PVOID));
[2]701 WinRegisterClass(hab,
[593]702 WC_BUBBLE,
[189]703 BubbleProc,
704 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
705 sizeof(ULONG) * 2);
[2]706 WinRegisterClass(hab,
[593]707 WC_STATUS,
[189]708 StatusProc,
709 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
710 sizeof(ULONG));
[2]711 WinRegisterClass(hab,
[593]712 WC_DIRSTATUS,
[189]713 DirTextProc,
714 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
715 sizeof(ULONG));
[2]716 WinRegisterClass(hab,
[593]717 WC_TREESTATUS,
[189]718 TreeStatProc,
719 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
720 sizeof(ULONG));
[2]721 WinRegisterClass(hab,
[593]722 WC_ARCSTATUS,
[189]723 ArcTextProc,
724 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
725 sizeof(ULONG));
[2]726 WinRegisterClass(hab,
[593]727 WC_COLSTATUS,
[189]728 CollectorTextProc,
729 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
730 sizeof(ULONG));
[2]731 WinRegisterClass(hab,
[593]732 WC_SEESTATUS,
[189]733 SeeStatusProc,
734 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
735 sizeof(ULONG));
[2]736 WinRegisterClass(hab,
[593]737 WC_VIEWSTATUS,
[189]738 ViewStatusProc,
739 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
740 sizeof(ULONG));
[2]741 WinRegisterClass(hab,
[593]742 WC_ERRORWND,
[189]743 NotifyWndProc,
744 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
745 sizeof(PVOID));
[2]746 WinRegisterClass(hab,
[593]747 WC_MINITIME,
[189]748 MiniTimeProc,
749 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
750 sizeof(PVOID) * 2);
[2]751 WinRegisterClass(hab,
[593]752 WC_DATABAR,
[551]753 DataProc, CS_SIZEREDRAW, sizeof(PVOID));
[2]754 WinRegisterClass(hab,
[593]755 WC_TREEOPENBUTTON,
[189]756 OpenButtonProc,
757 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
758 sizeof(PVOID));
[2]759 WinRegisterClass(hab,
[593]760 WC_AUTOVIEW,
[189]761 AutoViewProc,
762 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
763 sizeof(PVOID));
[2]764 WinRegisterClass(hab,
[593]765 WC_LED,
[189]766 LEDProc,
767 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
768 sizeof(PVOID));
[2]769
770 /*
[201]771 * set some defaults (note: everything else automatically initialized
[2]772 * to 0)
773 */
774 detailssize = detailsea = detailslwdate = detailslwtime = detailsattr =
[189]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;
[2]783 ulCnrType = CCS_EXTENDSEL;
784 FilesToGet = 128L;
785 AutoviewHeight = 48L;
[189]786 strcpy(printer, "PRN");
[2]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
[201]797 // load preferences from profile (INI) file
798 size = sizeof(BOOL);
799 PrfQueryProfileData(fmprof,
[551]800 appname, "ShowTarget", (PVOID) & fShowTarget, &size);
[201]801 size = sizeof(BOOL);
[551]802 PrfQueryProfileData(fmprof, appname, "CheckMM", (PVOID) & fCheckMM, &size);
[201]803 size = sizeof(BOOL);
804 PrfQueryProfileData(fmprof,
805 appname,
[551]806 "ChangeTarget", (PVOID) & fChangeTarget, &size);
[201]807 size = sizeof(BOOL);
808 PrfQueryProfileData(fmprof,
809 appname,
[551]810 "ConfirmTarget", (PVOID) & fConfirmTarget, &size);
[201]811 size = sizeof(BOOL);
812 PrfQueryProfileData(fmprof,
813 FM3Str,
[551]814 "CustomFileDlg", (PVOID) & fCustomFileDlg, &size);
[201]815 size = sizeof(BOOL);
816 PrfQueryProfileData(fmprof,
[551]817 FM3Str, "SaveMiniCmds", (PVOID) & fSaveMiniCmds, &size);
[201]818 size = sizeof(BOOL);
819 PrfQueryProfileData(fmprof,
[551]820 appname, "SaveBigCmds", (PVOID) & fSaveBigCmds, &size);
[201]821 size = sizeof(BOOL);
822 PrfQueryProfileData(fmprof,
[551]823 appname, "NoFoldMenu", (PVOID) & fNoFoldMenu, &size);
[201]824 size = sizeof(BOOL);
825 PrfQueryProfileData(fmprof,
[551]826 FM3Str, "ThreadNotes", (PVOID) & fThreadNotes, &size);
827 size = sizeof(BOOL);
828 PrfQueryProfileData(fmprof, FM3Str, "Prnpagenums", (PVOID) & prnpagenums,
[201]829 &size);
830 size = sizeof(BOOL);
831 PrfQueryProfileData(fmprof, FM3Str, "Prnalt", (PVOID) & prnalt, &size);
832 size = sizeof(BOOL);
[551]833 PrfQueryProfileData(fmprof, FM3Str, "Prnformat", (PVOID) & prnformat,
834 &size);
[201]835 size = sizeof(BOOL);
836 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedbefore",
837 (PVOID) & prnformfeedbefore, &size);
838 size = sizeof(BOOL);
839 PrfQueryProfileData(fmprof,
840 FM3Str,
[551]841 "Prnformfeedafter", (PVOID) & prnformfeedafter, &size);
[201]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);
[551]848 PrfQueryProfileData(fmprof, FM3Str, "Prnlength", (PVOID) & prnlength,
849 &size);
[201]850 size = sizeof(ULONG);
[551]851 PrfQueryProfileData(fmprof, FM3Str, "Prntmargin", (PVOID) & prntmargin,
852 &size);
[201]853 size = sizeof(ULONG);
[551]854 PrfQueryProfileData(fmprof, FM3Str, "Prnbmargin", (PVOID) & prnbmargin,
855 &size);
[201]856 size = sizeof(ULONG);
[551]857 PrfQueryProfileData(fmprof, FM3Str, "Prnlmargin", (PVOID) & prnlmargin,
858 &size);
[201]859 size = sizeof(ULONG);
[551]860 PrfQueryProfileData(fmprof, FM3Str, "Prnrmargin", (PVOID) & prnrmargin,
861 &size);
[201]862 size = sizeof(ULONG);
[551]863 PrfQueryProfileData(fmprof, FM3Str, "Prnspacing", (PVOID) & prnspacing,
864 &size);
[201]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);
[551]887 PrfQueryProfileData(fmprof, FM3Str, "LookInDir", (PVOID) & fLookInDir,
888 &size);
889 PrfQueryProfileString(fmprof, appname, "DefArc", NULL, szDefArc,
890 sizeof(szDefArc));
[201]891 size = sizeof(ULONG);
892 PrfQueryProfileData(fmprof, FM3Str, "AutoviewHeight",
893 (PVOID) & AutoviewHeight, &size);
894 size = sizeof(BOOL);
[551]895 PrfQueryProfileData(fmprof, FM3Str, "KeepCmdLine", (PVOID) & fKeepCmdLine,
896 &size);
897 if (strcmp(realappname, "FM/4")) {
[2]898 size = sizeof(BOOL);
899 PrfQueryProfileData(fmprof,
[551]900 FM3Str, "MoreButtons", (PVOID) & fMoreButtons, &size);
[2]901 size = sizeof(BOOL);
902 PrfQueryProfileData(fmprof,
[551]903 FM3Str, "Drivebar", (PVOID) & fDrivebar, &size);
[201]904 }
905 else
906 fDrivebar = fMoreButtons = TRUE;
907 size = sizeof(BOOL);
908 PrfQueryProfileData(fmprof,
[551]909 appname, "NoSearch", (PVOID) & fNoSearch, &size);
[201]910 size = sizeof(BOOL);
911 PrfQueryProfileData(fmprof,
[551]912 appname, "GuessType", (PVOID) & fGuessType, &size);
[201]913 size = sizeof(BOOL);
914 PrfQueryProfileData(fmprof,
[551]915 appname, "ViewChild", (PVOID) & fViewChild, &size);
[201]916 size = sizeof(BOOL);
[551]917 PrfQueryProfileData(fmprof, appname, "ShowEnv", (PVOID) & fShowEnv, &size);
[201]918 size = sizeof(BOOL);
919 PrfQueryProfileData(fmprof,
[551]920 appname, "LeaveTree", (PVOID) & fLeaveTree, &size);
[201]921 size = sizeof(BOOL);
922 PrfQueryProfileData(fmprof, FM3Str, "Comments", (PVOID) & fComments, &size);
923 size = sizeof(ULONG);
[551]924 PrfQueryProfileData(fmprof, appname, "WS_ANIMATE", (PVOID) & fwsAnimate,
925 &size);
[201]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);
[551]933 PrfQueryProfileData(fmprof, FM3Str, "ToolbarHelp", (PVOID) & fToolbarHelp,
934 &size);
[201]935 size = sizeof(BOOL);
[551]936 PrfQueryProfileData(fmprof, FM3Str, "OtherHelp", (PVOID) & fOtherHelp,
937 &size);
[201]938 size = sizeof(BOOL);
[551]939 PrfQueryProfileData(fmprof, FM3Str, "DrivebarHelp", (PVOID) & fDrivebarHelp,
940 &size);
[201]941 size = sizeof(BOOL);
942 PrfQueryProfileData(fmprof,
[551]943 appname, "AutoAddDirs", (PVOID) & fAutoAddDirs, &size);
[201]944 size = sizeof(BOOL);
945 PrfQueryProfileData(fmprof,
946 appname,
[551]947 "AutoAddAllDirs", (PVOID) & fAutoAddAllDirs, &size);
[201]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);
[551]975 PrfQueryProfileData(fmprof, appname, "DataToFore", (PVOID) & fDataToFore,
976 &size);
[201]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);
[551]984 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", (PVOID) & fSplitStatus,
985 &size);
[201]986 size = sizeof(BOOL);
987 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract",
988 (PVOID) & fFolderAfterExtract, &size);
989 size = sizeof(BOOL);
[551]990 PrfQueryProfileData(fmprof, FM3Str, "DullDatabar", (PVOID) & fDullMin,
991 &size);
[201]992 size = sizeof(BOOL);
993 PrfQueryProfileData(fmprof, appname, "BlueLED", (PVOID) & fBlueLED, &size);
994 size = sizeof(BOOL);
[551]995 PrfQueryProfileData(fmprof, appname, "ConfirmDelete",
996 (PVOID) & fConfirmDelete, &size);
[201]997 size = sizeof(BOOL);
[551]998 PrfQueryProfileData(fmprof, FM3Str, "SaveState", (PVOID) & fSaveState,
999 &size);
[201]1000 size = sizeof(BOOL);
[551]1001 PrfQueryProfileData(fmprof, appname, "SyncUpdates", (PVOID) & fSyncUpdates,
1002 &size);
[201]1003 size = sizeof(BOOL);
[551]1004 PrfQueryProfileData(fmprof, appname, "LoadSubject", (PVOID) & fLoadSubject,
1005 &size);
[201]1006 size = sizeof(BOOL);
[551]1007 PrfQueryProfileData(fmprof, appname, "UnHilite", (PVOID) & fUnHilite,
[201]1008 &size);
1009 size = sizeof(BOOL);
[551]1010 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards",
1011 (PVOID) & fTileBackwards, &size);
[201]1012 size = sizeof(BOOL);
[551]1013 PrfQueryProfileData(fmprof, appname, "LoadLongname",
1014 (PVOID) & fLoadLongnames, &size);
1015 size = sizeof(BOOL);
1016 PrfQueryProfileData(fmprof, appname, "VerifyWrites", (PVOID) & fVerify,
1017 &size);
[201]1018 DosSetVerify(fVerify);
1019 size = sizeof(BOOL);
[551]1020 PrfQueryProfileData(fmprof, appname, "DontMoveMouse",
1021 (PVOID) & fDontMoveMouse, &size);
[201]1022 size = sizeof(BOOL);
[551]1023 PrfQueryProfileData(fmprof, appname, "NoIconsFiles",
1024 (PVOID) & fNoIconsFiles, &size);
[201]1025 size = sizeof(BOOL);
[551]1026 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", (PVOID) & fNoIconsDirs,
1027 &size);
[201]1028 size = sizeof(BOOL);
[551]1029 PrfQueryProfileData(fmprof, appname, "ForceUpper", (PVOID) & fForceUpper,
1030 &size);
[201]1031 size = sizeof(BOOL);
[551]1032 PrfQueryProfileData(fmprof, appname, "ForceLower", (PVOID) & fForceLower,
1033 &size);
[201]1034 size = sizeof(BOOL);
[551]1035 PrfQueryProfileData(fmprof, FM3Str, "TextTools", (PVOID) & fTextTools,
1036 &size);
[201]1037 size = sizeof(BOOL);
[551]1038 PrfQueryProfileData(fmprof, FM3Str, "ToolTitles", (PVOID) & fToolTitles,
1039 &size);
[201]1040 size = sizeof(BOOL);
[551]1041 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", (PVOID) & fDCOpens,
1042 &size);
[201]1043 size = sizeof(BOOL);
[551]1044 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon",
1045 (PVOID) & fLinkSetsIcon, &size);
[201]1046 size = sizeof(INT);
1047 PrfQueryProfileData(fmprof, appname, "Sort", (PVOID) & sortFlags, &size);
1048 size = sizeof(INT);
[551]1049 PrfQueryProfileData(fmprof, appname, "TreeSort", (PVOID) & TreesortFlags,
1050 &size);
[201]1051 size = sizeof(INT);
1052 PrfQueryProfileData(fmprof,
1053 appname,
[551]1054 "CollectorSort", (PVOID) & CollectorsortFlags, &size);
[201]1055 size = sizeof(targetdir);
[551]1056 PrfQueryProfileData(fmprof, appname, "Targetdir", (PVOID) targetdir, &size);
[201]1057 if (!IsValidDir(targetdir))
1058 *targetdir = 0;
1059 size = sizeof(extractpath);
1060 PrfQueryProfileData(fmprof,
[551]1061 appname, "ExtractPath", (PVOID) extractpath, &size);
[201]1062 if (!IsValidDir(extractpath))
1063 *extractpath = 0;
1064 size = sizeof(printer);
1065 PrfQueryProfileData(fmprof, appname, "Printer", (PVOID) printer, &size);
1066 size = sizeof(dircompare);
[551]1067 PrfQueryProfileData(fmprof, appname, "DirCompare", (PVOID) dircompare,
1068 &size);
[201]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);
[551]1090 PrfQueryProfileData(fmprof, FM3Str, "LastToolBox", (PVOID) lasttoolbox,
1091 &size);
[201]1092 size = sizeof(BOOL);
[551]1093 PrfQueryProfileData(fmprof, appname, "FollowTree", (PVOID) & fFollowTree,
1094 &size);
[201]1095 size = sizeof(BOOL);
[551]1096 PrfQueryProfileData(fmprof, appname, "StartMaximized",
1097 (PVOID) & fStartMaximized, &size);
1098 if (!fStartMaximized) {
[2]1099 size = sizeof(BOOL);
[551]1100 PrfQueryProfileData(fmprof, appname, "StartMinimized",
1101 (PVOID) & fStartMinimized, &size);
[2]1102 }
[201]1103 size = sizeof(BOOL);
[551]1104 PrfQueryProfileData(fmprof, appname, "DefaultCopy", (PVOID) & fCopyDefault,
1105 &size);
[201]1106 size = sizeof(BOOL);
[551]1107 PrfQueryProfileData(fmprof, appname, "IdleCopy", (PVOID) & fRealIdle,
1108 &size);
[201]1109 size = sizeof(BOOL);
1110 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible",
1111 (PVOID) & fArcStuffVisible, &size);
1112 size = sizeof(BOOL);
[551]1113 PrfQueryProfileData(fmprof, FM3Str, "NoTreeGap", (PVOID) & fNoTreeGap,
[201]1114 &size);
1115 size = sizeof(BOOL);
[551]1116 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS",
1117 (PVOID) & fVTreeOpensWPS, &size);
[201]1118 size = sizeof(BOOL);
[551]1119 PrfQueryProfileData(fmprof, appname, "RemoteBug", (PVOID) & fRemoteBug,
[201]1120 &size);
1121 size = sizeof(BOOL);
[551]1122 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg",
1123 (PVOID) & fDragndropDlg, &size);
1124 size = sizeof(BOOL);
[201]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);
[551]1131 PrfQueryProfileData(fmprof, appname, "QuickArcFind",
1132 (PVOID) & fQuickArcFind, &size);
[201]1133 size = sizeof(BOOL);
[551]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,
[201]1141 &size);
1142 size = sizeof(ULONG);
[551]1143 PrfQueryProfileData(fmprof, appname, "FilesToGet", (PVOID) & FilesToGet,
[201]1144 &size);
1145 size = sizeof(BOOL);
1146 PrfQueryProfileData(fmprof, FM3Str, "AutoView", (PVOID) & fAutoView, &size);
1147 size = sizeof(BOOL);
[551]1148 PrfQueryProfileData(fmprof, FM3Str, "FM2Deletes", (PVOID) & fFM2Deletes,
1149 &size);
[2]1150
1151 /* load pointers and icons we use */
[189]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);
[552]1166 hptrReadonly = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_READONLY_ICON);
[189]1167 hptrLast = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, LASTITEM_ICON);
1168 hptrRemote = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOTE_ICON);
[552]1169 hptrVirtual = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, VIRTUAL_ICON);
1170 hptrRamdisk = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, RAMDISK_ICON);
[189]1171 if (!fNoDead)
1172 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER_ICON);
[2]1173 else
[189]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);
[2]1179
[201]1180 // set up color array used by seeall.c and newview.c color dialog
1181
[189]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;
[2]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
[189]1202HWND StartFM3(HAB hab, INT argc, CHAR ** argv)
1203{
[201]1204 HWND hwndFrame;
1205 HWND hwndClient;
1206 UINT x;
[189]1207 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
[551]1208 FCF_SIZEBORDER | FCF_MINMAX |
1209 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
[2]1210
[551]1211 for (x = 1; x < argc; x++) {
[201]1212 if (*argv[x] == '~' && !argv[x][1])
1213 fReminimize = TRUE;
1214 if (*argv[x] == '+' && !argv[x][1])
1215 fLogFile = TRUE;
[551]1216 if (*argv[x] == '-') {
[201]1217 if (!argv[x][1])
1218 fNoSaveState = TRUE;
1219 else
1220 strcpy(profile, &argv[x][1]);
[2]1221 }
1222 }
1223
1224 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
[189]1225 WS_VISIBLE,
1226 &FrameFlags,
[593]1227 WC_MAINWND,
[189]1228 NULL,
1229 WS_VISIBLE | WS_ANIMATE,
[551]1230 FM3ModHandle, MAIN_FRAME, &hwndClient);
1231 if (hwndFrame) {
1232 WinSetWindowUShort(hwndFrame, QWS_ID, MAIN_FRAME);
1233 if (!WinRestoreWindowPos(FM2Str, "MainWindowPos", hwndFrame)) {
[2]1234
1235 ULONG fl = SWP_MOVE | SWP_SIZE;
1236 RECTL rcl;
[189]1237 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1238 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
[2]1239
[551]1240 WinQueryWindowRect(HWND_DESKTOP, &rcl);
[2]1241 rcl.yBottom += icz;
1242 rcl.yTop -= bsz;
1243 rcl.xLeft += bsz;
1244 rcl.xRight -= bsz;
1245 WinSetWindowPos(hwndFrame,
[189]1246 HWND_TOP,
1247 rcl.xLeft,
1248 rcl.yBottom,
[551]1249 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
[2]1250 }
[189]1251 if (fLogFile)
[551]1252 LogFileHandle = _fsopen("FM2.LOG", "a+", SH_DENYWR);
[189]1253 if (hwndHelp)
[551]1254 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1255 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
[2]1256 }
1257 return hwndFrame;
1258}
[32]1259
[189]1260int CheckVersion(int vermajor, int verminor)
1261{
[179]1262 int ok = 0;
[32]1263
[179]1264 // fixme to do useful check - was missing in base source
1265
[32]1266#if 0
[551]1267 if (vermajor && verminor) {
[32]1268 *vermajor = VERMAJOR;
1269 *verminor = VERMINOR;
[179]1270 ok = 1;
[32]1271 }
1272#endif
[189]1273
[179]1274 ok = 1;
[32]1275
[179]1276 return ok;
[32]1277}
Note: See TracBrowser for help on using the repository browser.