source: trunk/dll/init.c@ 1069

Last change on this file since 1069 was 1069, checked in by Gregg Young, 17 years ago

Fixes trap on viewing multiple files from an archive Ticket 248. Also includes initial code for using TMP directory for Temp files.

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