source: trunk/dll/init.c@ 985

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

Update sizes dialog (ticket 44); Make max command line length user settable (ticket 199); use xfree for free in most cases (ticket 212); initial code to check for valid ini file (ticket 102); Some additional refactoring and structure rework; Some documentation updates;

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