source: trunk/dll/init.c@ 1739

Last change on this file since 1739 was 1739, checked in by Gregg Young, 11 years ago

Cleanup of readonly check code suppress spurious error on blocked directory delete and eliminated the check on additional temp file deletes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 64.9 KB
RevLine 
[32]1
2/***********************************************************************
3
4 $Id: init.c 1739 2014-02-22 21:06:09Z gyoung $
5
6 Initialization
7
8 Copyright (c) 1993-98 M. Kimes
[1498]9 Copyright (c) 2001, 2010 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
[1335]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
[1335]49 all the details view settings (both the global variables and those in the
50 DIRCNRDATA struct) into a new struct: DETAILS_SETTINGS.
[1075]51 16 JUL 08 GKY Use TMP directory for temp files
[1074]52 17 Jul 08 SHL Reduce code bulk in fUseTmp setup
[1082]53 19 Jul 08 GKY Use pFM2SaveDirectory, MakeTempName and move temp files to TMP subdirectory if (TMP).
[1083]54 20 Jul 08 JBS Ticket 114: Support user-selectable env. strings in Tree container.
[1089]55 20 Jul 08 GKY Add support to delete orphaned tmp directories without deleting tmp of other
[1335]56 running sessions
[1112]57 23 Aug 08 GKY Check that space on TMP & FM2 save drives exceed 5 GiB; Done to allow user setting of
[1335]58 minimum size in future
[1303]59 29 Nov 08 GKY Remove or replace with a mutex semaphore DosEnterCriSec where appropriate.
[1306]60 30 Nov 08 GKY Add the option of creating a subdirectory from the arcname
[1335]61 for the extract path to arc container.
62 10 Dec 08 SHL Integrate exception handler support
[1358]63 25 Dec 08 GKY Add code to allow write verify to be turned off on a per drive basis
[1360]64 28 Dec 08 GKY Check for LVM.EXE and remove Refresh removable media menu item as appropriate
65 28 Dec 08 GKY Rework partition submenu to gray out unavailable items (check for existence of files)
[1394]66 and have no default choice.
[1375]67 01 Jan 09 GKY Add option to rescan tree container on eject of removable media
68 03 Jan 09 GKY Avoid dbl scan of drive on startup by checking for first rescan drive.
69 03 Jan 09 GKY Check for system that is protectonly to gray out Dos/Win command lines and prevent
[1394]70 Dos/Win programs from being inserted into the execute dialog with message why.
[1391]71 11 Jan 09 GKY Move strings that shouldn't be translated (font names etc) compile time variables
[1394]72 03 Feb 09 SHL Switch to STRINGTABLE
[1395]73 07 Feb 09 GKY Move repeated strings to PCSZs.
74 07 Feb 09 GKY Add *DateFormat functions to format dates based on locale
75 07 Feb 09 GKY Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error
[1400]76 08 Mar 09 GKY Additional strings move to PCSZs in init.c
[1402]77 08 Mar 09 GKY Removed variable aurguments from docopyf and unlinkf (not used)
78 14 Mar 09 GKY PCSZ strings moved to compile time initialization
79 14 Mar 09 GKY Prevent execution of UM_SHOWME while drive scan is occuring replaces check for
[1471]80 saved drive containers.
[1429]81 06 Jun 09 GKY Add option to show file system type or drive label in tree
[1438]82 28 Jun 09 GKY Added AddBackslashToPath() to remove repeatative code.
[1480]83 12 Jul 09 GKY Add xDosQueryAppType and xDosAlloc... to allow FM/2 to load in high memory
[1444]84 22 Jul 09 GKY Code changes to use semaphores to serialize drive scanning
85 22 Jul 09 GKY Fix failure to restore the notebook setting for saving container states or not
[1452]86 12 Sep 09 GKY Change protectonly check to check for VKBD being loaded instead of starting
[1471]87 command.com. Prevents hang (at least until a Dos program is started) on a system
88 that has a broken MDOS install.
[1479]89 15 Nov 09 GKY Add more PCSZs
[1480]90 22 Nov 09 GKY Fix FindSwapperDat so the check for large file support actually occurs if the
91 fall back to config.sys is used to find it; use bstripcr to streamline code.
[1482]92 13 Dec 09 GKY Fixed separate paramenters. Please note that appname should be used in
93 profile calls for user settings that work and are setable in more than one
94 miniapp; FM3Str should be used for setting only relavent to FM/2 or that
95 aren't user settable; realappname should be used for setting applicable to
96 one or more miniapp but not to FM/2
[1604]97 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR
98 CONSTANT * as CHAR *.
[1522]99 09 MAY 10 JBS Ticket 434: Make fDontSuggestAgain a "global" flag, not a per app flag
[1546]100 23 Oct 10 GKY Changes to populate and utilize a HELPTABLE for context specific help
[1553]101 20 Nov 10 GKY Rework scanning code to remove redundant scans, prevent double directory
102 entries in the tree container, fix related semaphore performance using
103 combination of event and mutex semaphores
[1554]104 20 Nov 10 GKY Check that pTmpDir IsValid and recreate if not found; Fixes hangs caused
105 by temp file creation failures.
[1560]106 03 Mar 11 SHL Try using FM3INI to create help instance if fm3.hlp not in current directory
[1604]107 06 Aug 11 GKY Fixed failure to initalize pFM2SaveDirectory if TEMP and TMP were not present
108 or invalid
[1642]109 22 Oct 11 GKY Thread notes dialog now reopens on startup if it was open on shutdown.
[1654]110 08 Jan 12 GKY Add support for changing PresParams in the notify status window
[1664]111 04 Aug 12 GKY Changes to use Unlock to unlock files if Unlock.exe is in path both from menu/toolbar and as part of
112 copy, move and delete operations
113 04 Aug 12 GKY Changes to allow copy and move over readonly files with a warning dialog; also added a warning dialog
114 for delete of readonly files
[1711]115 09 Feb 14 GKY Fix separate parameters. Moved to general page renamed separate settings
116 for apps.
[1712]117 09 Feb 14 GKY Modified wipeallf to allow suppression of the readonly warning on delete
118 of temporary files
[1720]119 16 Feb 14 GKY Add "#" command line switch to workaround problem with blank command shell
120 started from fm2 after fm2 has been started with stdout and stderr
121 redirected to a file.
[1739]122 22 Feb 14 GKY Cleanup of readonly check code suppress spurious error on blocked directory
123 delete and eliminated the check on additional temp file deletes
[32]124
125***********************************************************************/
126
[2]127#include <stdlib.h>
128#include <string.h>
129#include <share.h>
[1335]130#include <process.h> // getpid
[1224]131#include <time.h>
[1326]132#include <ctype.h>
[133]133
[803]134#define INCL_DOS
135#define INCL_WIN
136#define INCL_MMIOOS2
137#define INCL_GPI
138#define INCL_DOSERRORS
[841]139#define INCL_LONGLONG
[860]140#define INCL_DOSNLS
[803]141#include <os2.h>
142#include <os2me.h>
143
144#define DEFINE_GLOBALS 1
145
[1177]146#include "fm3dll.h"
[1224]147#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
148#include "init.h"
[1209]149#include "mkdir.h" // Data declaration(s)
150#include "dircnrs.h" // Data declaration(s)
151#include "comp.h" // Data declaration(s)
152#include "cmdline.h" // Data declaration(s)
153#include "fm2cmd.h" // Data declaration(s)
[1471]154#include "printer.h" // Data declaration(s)
155#include "flesh.h" // Data declaration(s)
156#include "worker.h" // Data declaration(s)
157#include "filldir.h" // Data declaration(s)
158#include "defview.h" // Data declaration(s)
159#include "draglist.h" // Data declaration(s)
[2]160#include "fm3dlg.h"
[133]161#include "datamin.h"
[2]162#include "tools.h"
163#include "fm3str.h"
164#include "version.h"
[1471]165#include "pathutil.h" // BldFullPathName
166#include "arccnrs.h" // ArcClientWndProc
167#include "errutil.h" // Dos_Error...
168#include "strutil.h" // GetPString
169#include "valid.h" // ArgDriveFlags
170#include "autoview.h" // AutoViewProc
[1156]171#include "mainwnd.h" // BubbleProc, ChildButtonProc, DriveBackProc,
[1335]172 // DriveProc, LEDProc, MainWndProc, StatusProc
173 // ToolBackProc
[1156]174#include "collect.h" // CollectorClientWndProc, CollectorTextProc
175#include "getnames.h" // CustomFileDlg
176#include "notify.h" // EndNote
177#include "valid.h" // FillInDriveFlags, IsValidDir
178#include "inis.h" // IniProc
179#include "viewer.h" // MLEEditorProc
180#include "mainwnd2.h" // MainWndProc2
181#include "notify.h" // NotifyWndProc
182#include "treecnr.h" // OpenButtonProc
[1209]183#include "seeall.h" // SeeAllWndProc, SeeStatusProc
184#include "timer.h" // StartTimer, StopTimer
185#include "treecnr.h" // TreeClientWndProc, TreeStatProc
186#include "newview.h" // ViewStatusProc, ViewWndProc
187#include "subj.h" // Subject
188#include "select.h" // UnHilite
189#include "dirs.h" // save_dir
190#include "copyf.h" // unlinkf
191#include "wrappers.h" // xDosSetPathInfo
[1156]192#include "misc.h" // HeapThread, LoadDetailsSwitches
193#include "notebook.h" // command line variables (editor etc)
[1209]194#include "strips.h" // bstrip
195#include "killproc.h" // GetDosPgmName
196#include "srchpath.h" // searchpath
[1012]197#include "fortify.h"
[1335]198#include "excputil.h" // xbeginthread
[1369]199#include "systemf.h" // runemf2
[2]200
[189]201extern int _CRT_init(void);
[2]202extern void _CRT_term(void);
203
[952]204#ifdef __WATCOMC__
205#define a(x) #x
206#define b(x) a(x)
207// Must be global to prevent warnings
208PSZ pszBuiltWith = "Built with OpenWatcom version " b(__WATCOMC__);
209#undef b
210#undef a
211#endif
212
[1224]213static VOID FindSwapperDat(VOID);
[1217]214
[1209]215// Data definitions
[339]216static PSZ pszSrcFile = __FILE__;
[1377]217unsigned __MaxThreads = {48};
[2]218
[1209]219#pragma data_seg(GLOBAL1)
[1313]220HMTX hmtxFM2Delete;
[1303]221HMTX hmtxFM2Globals;
[1553]222HMTX hmtxScanning;
[1551]223HEV hevTreeCnrScanComplete;
[1209]224ULONG OS2ver[2];
225PFNWP PFNWPCnr;
226PFNWP PFNWPMLE;
227CHAR ThousandsSeparator[2];
[1395]228CHAR DateSeparator[2];
229CHAR TimeSeparator[2];
230ULONG ulTimeFmt;
231ULONG ulDateFmt;
[1551]232ULONG ulScanPostCnt;
[1451]233BOOL fDontSuggestAgain;
[1320]234BOOL fInitialDriveScan;
[1209]235BOOL fAmAV2;
236BOOL fChangeTarget;
237BOOL fIniExisted;
238BOOL fLogFile;
[1369]239BOOL fProtectOnly;
[1209]240BOOL fReminimize;
241BOOL fWantFirstTimeInit;
[1720]242BOOL fUseShellEnv;
[1402]243//BOOL fDrivetoSkip[26];
[1209]244HPOINTER hptrApp;
245HPOINTER hptrArc;
246HPOINTER hptrArrow;
247HPOINTER hptrArt;
248HPOINTER hptrBusy;
249HPOINTER hptrCDROM;
250HPOINTER hptrDrive;
251HPOINTER hptrEW;
252HPOINTER hptrFloppy;
253HPOINTER hptrNS;
254HPOINTER hptrRamdisk;
255HPOINTER hptrRemote;
256HPOINTER hptrRemovable;
257HPOINTER hptrVirtual;
258HPOINTER hptrZipstrm;
259CHAR *pFM2SaveDirectory;
260CHAR *pTmpDir;
261
262#pragma data_seg(GLOBAL2)
[1402]263PCSZ PCSZ_ARCHIVERBB2 = "ARCHIVER.BB2";
264PCSZ PCSZ_ASSOCDAT = "ASSOC.DAT";
265PCSZ PCSZ_CMDLINESDAT = "CMDLINES.DAT";
266PCSZ PCSZ_CMDMINIDAT = "CMDMINI.DAT";
267PCSZ PCSZ_COMMANDSDAT = "COMMANDS.DAT";
268PCSZ PCSZ_FILTERSDAT = "FILTERS.DAT";
269PCSZ PCSZ_GREPMASKDAT = "GREPMASK.DAT";
270PCSZ PCSZ_PATTERNSDAT = "PATTERNS.DAT";
271PCSZ PCSZ_RESOURCEDAT = "RESOURCE.DAT";
272PCSZ PCSZ_QUICKTLSDAT = "QUICKTLS.DAT";
273PCSZ PCSZ_FM3TOOLSDAT = "FM3TOOLS.DAT";
274PCSZ PCSZ_USERDIRSDAT = "USERDIRS.DAT";
275PCSZ PCSZ_FM2PLAYEXE = "FM2PLAY.EXE";
[1479]276PCSZ PCSZ_IMAGEEXE = "IMAGE.EXE";
[1402]277PCSZ PCSZ_FM2PLAYTEMP = "$FM2PLAY.$$$";
278PCSZ PCSZ_LVMGUICMD = "LVMGUI.CMD";
279PCSZ PCSZ_DFSOS2EXE = "DFSOS2.EXE";
280PCSZ PCSZ_MINILVMEXE = "MINILVM.EXE";
281PCSZ PCSZ_FDISKPMEXE = "FDISKPM.EXE";
282PCSZ PCSZ_LVMEXE = "LVM.EXE";
[1664]283PCSZ PCSZ_UNLOCKEXE = "UNLOCK.EXE";
[1402]284PCSZ PCSZ_ARCCNR = "ArcCnr";
285PCSZ PCSZ_COLLECTOR = "Collector";
286PCSZ PCSZ_DIRCNR = "DirCnr";
[1409]287PCSZ PCSZ_DIRCMP = "DirCmp";
[1402]288PCSZ PCSZ_DIRSIZES = "DirSizes";
[1654]289PCSZ PCSZ_NOTIFYWND = "NotifyWnd";
[1402]290PCSZ PCSZ_TOOLBAR = "ToolBar";
291PCSZ PCSZ_TREECNR = "TreeCnr";
292PCSZ PCSZ_SHUTDOWNSTATE = "FM2Shutdown";
293PCSZ PCSZ_FM2TEMPTEXT = "FM/2_Temp";
294PCSZ DRF_FM2ARCHIVE = "DRF_FM2ARCHIVE";
295PCSZ DRMDRFFM2ARC = "<DRM_FM2ARCMEMBER,DRF_FM2ARCHIVE>";
296PCSZ DRMDRFOS2FILE = "<DRM_OS2FILE,DRF_UNKNOWN>";
297PCSZ DRM_FM2ARCMEMBER = "DRM_FM2ARCMEMBER";
298PCSZ DRM_OS2FILE = "DRM_OS2FILE";
299PCSZ FM2Str = "FM/2";
[1209]300HMODULE FM3DllHandle;
[1402]301PCSZ FM3Folder = "<FM3_Folder>";
[1436]302PCSZ FNT_HELVETICA = "Helvetica";
[1402]303PCSZ FNT_6HELVETICA = "6.Helvetica";
304PCSZ FNT_8HELVETICA = "8.Helvetica";
305PCSZ FNT_8HELVETICABOLD = "8.Helvetica.Bold";
306PCSZ FNT_10SYSTEMMONOTEXT = "10.System Monospaced";
307PCSZ FNT_10SYSTEMPROPORT = "10.System Proportional";
308PCSZ FNT_2SYSTEMVIO = "2.System VIO";
309PCSZ FNT_4SYSTEMVIO = "4.System VIO";
310PCSZ FNT_10SYSTEMVIO = "10.System VIO";
311PCSZ FNT_8TIMESNEWROMAN = "8.Times New Roman";
[1209]312CHAR HomePath[CCHMAXPATH];
[1402]313PCSZ LONGNAME = ".LONGNAME";
314CHAR *NullStr = "";
315PCSZ PCSZ_CM_ALLOCRECORD = "CM_ALLOCRECORD";
[1673]316PCSZ PCSZ_QUERYCNRINFO = "CM_QUERYCNRINFO";
[1402]317PCSZ PCSZ_DOSCREATEMUTEXSEM = "DosCreateMutexSem";
[1450]318PCSZ PCSZ_DOSCREATEEVENTSEM = "DosCreateEventSem";
[1402]319PCSZ PCSZ_DOSDUPHANDLE = "DosDupHandle";
320PCSZ PCSZ_DOSGETINFOBLOCKS = "DosGetInfoBlocks";
321PCSZ PCSZ_DOSQUERYPATHINFO = "DosQueryPathInfo";
322PCSZ PCSZ_DOSSEARCHPATH = "DosSearchPath";
323PCSZ PCSZ_DRGACCESSDRAGINFO = "DrgAccessDraginfo";
324PCSZ PCSZ_POSTMSG = "PostMsg";
325PCSZ PCSZ_WINCREATEWINDOW = "WinCreateWindow";
326PCSZ PCSZ_WINLOADACCELTABLE = "WinLoadAccelTable";
327PCSZ PCSZ_WINSETACCELTABLE = "WinSetAccelTable";
328PCSZ PCSZ_INIQUERYPRFTEXT = "PrfQueryProfile";
329PCSZ PCSZ_PRFOPENPROFILEFAILED = "PrfOpenProfile failed for %s";
330PCSZ PCSZ_PRFQUERYPROFILEDATA = "PrfQueryProfileData";
331PCSZ PCSZ_PRFQUERYPROFILESIZE = "PrfQueryProfileSize";
332PCSZ PCSZ_PRFQUERYPROFILESTRING = "PrfQueryProfileString";
333PCSZ PCSZ_FILLDIRQCURERRTEXT = "DosQCurDisk";
334PCSZ PCSZ_NODATA = "No Data";
[1438]335PCSZ PCSZ_BACKSLASH = "\\";
[1402]336PCSZ PCSZ_STARDOTEXE = "*.EXE";
337PCSZ PCSZ_STARDOTINI = "*.INI";
338PCSZ PCSZ_STARDOTLST = "*.LST";
339PCSZ PCSZ_STARDOTPMD = "*.PMD";
340PCSZ PCSZ_STARDOTTXT = "*.TXT";
[1607]341PCSZ PCSZ_FM3DOTINI = "FM3.INI";
342PCSZ PCSZ_FM3INI = "FM3INI";
343PCSZ PCSZ_FM3INIDOTBAK = "FM3INI.BAK";
344PCSZ PCSZ_FM3INIDOTBAD = "FM3INI.BAD";
345PCSZ PCSZ_FM3INIDOTBAD2 = "FM3INI.BAD2";
346PCSZ PCSZ_FM3RES = "FM3RES";
347PCSZ PCSZ_FM3DOTHLP = "FM3.HLP";
[1402]348PCSZ PCSZ_DOTEXE = ".EXE";
349PCSZ PCSZ_DOTCOM = ".COM";
350PCSZ PCSZ_DOTCMD = ".CMD";
351PCSZ PCSZ_DOTBTM = ".BTM";
352PCSZ PCSZ_DOTBAT = ".BAT";
353PCSZ PCSZ_DOTLST = ".LST";
354PCSZ PCSZ_DOTTLS = ".TLS";
355PCSZ PCSZ_DOTHLP = ".HLP";
356PCSZ PCSZ_DOTINF = ".INF";
357PCSZ PCSZ_DOTMP3 = ".MP3";
[1479]358PCSZ PCSZ_DOTMPG = ".MPG";
359PCSZ PCSZ_DOTMPEG = ".MPEG";
[1402]360PCSZ PCSZ_DOTOGG = ".OGG";
361PCSZ PCSZ_DOTFLAC = ".FLAC";
362PCSZ PCSZ_DOTJPEG = ".JPEG";
363PCSZ PCSZ_DOTJPG = ".JPG";
364PCSZ PCSZ_DOTICO = ".ICO";
365PCSZ PCSZ_DOTPTR = ".PTR";
366PCSZ PCSZ_DOTBB2 = ".BB2";
367PCSZ PCSZ_DOTBMP = ".BMP";
368PCSZ PCSZ_DOTCOMMENTS = ".COMMENTS";
369PCSZ PCSZ_PATH = "PATH";
370PCSZ PCSZ_LIBPATH = "LIBPATH";
371CHAR *pLibPathStrict = "SET LIBPATHSTRICT=TRUE";
372PCSZ PCSZ_WPURLDEFAULTSETTINGS = "WPURLDEFAULTSETTINGS";
373PCSZ Settings = "SETTINGS";
374PCSZ Details = "DETAILS";
375PCSZ PCSZ_TREE = "TREE";
376PCSZ PCSZ_ICON = "ICON";
[1209]377CHAR SwapperDat[CCHMAXPATH];
[1402]378PCSZ WC_OBJECTWINDOW = "WC_OBJECTWINDOW";
379PCSZ WC_BUBBLE = "WC_BUBBLE";
380PCSZ WC_TOOLBUTTONS = "WC_TOOLBUTTONS";
381PCSZ WC_DRIVEBUTTONS = "WC_DRIVEBUTTONS";
382PCSZ WC_DIRCONTAINER = "WC_DIRCONTAINER";
383PCSZ WC_DIRSTATUS = "WC_DIRSTATUS";
384PCSZ WC_TREECONTAINER = "WC_TREECONTAINER";
385PCSZ WC_TREEOPENBUTTON = "WC_TREEOPENBUTTON";
386PCSZ WC_TREESTATUS = "WC_TREESTATUS";
387PCSZ WC_MAINWND = "WC_MAINWND";
388PCSZ WC_MAINWND2 = "WC_MAINWND2";
389PCSZ WC_AUTOVIEW = "WC_AUTOVIEW";
390PCSZ WC_LED = "WC_LED";
391PCSZ WC_COLLECTOR = "WC_COLLECTOR";
392PCSZ WC_COLSTATUS = "WC_COLSTATUS";
393PCSZ WC_STATUS = "WC_STATUS";
394PCSZ WC_TOOLBACK = "WC_TOOLBACK";
395PCSZ WC_DRIVEBACK = "WC_DRIVEBACK";
396PCSZ WC_ARCCONTAINER = "WC_ARCCONTAINER";
397PCSZ WC_ARCSTATUS = "WC_ARCSTATUS";
398PCSZ WC_MLEEDITOR = "WC_MLEEDITOR";
399PCSZ WC_INIEDITOR = "WC_INIEDITOR";
400PCSZ WC_SEEALL = "WC_SEEALL";
401PCSZ WC_NEWVIEW = "WC_NEWVIEW";
402PCSZ WC_SEESTATUS = "WC_SEESTATUS";
403PCSZ WC_VIEWSTATUS = "WC_VIEWSTATUS";
404PCSZ WC_ERRORWND = "WC_ERRORWND";
405PCSZ WC_MINITIME = "WC_MINITIME";
406PCSZ WC_DATABAR = "WC_DATABAR";
[1209]407CHAR profile[CCHMAXPATH];
[1482]408ULONGLONG ullTmpSpaceNeeded = 5120000;
[1156]409
[985]410BOOL CheckFileHeader(CHAR *filespec, CHAR *signature, LONG offset);
411
[189]412VOID FindSwapperDat(VOID)
413{
[201]414 CHAR filename[] = "C:\\CONFIG.SYS";
415 CHAR input[8192];
416 CHAR *p;
417 CHAR *pp;
[189]418 FILE *fp;
[849]419 FILEFINDBUF3L ffb;
[201]420 ULONG nm;
421 ULONG size = sizeof(SwapperDat);
[189]422 HDIR hdir = HDIR_CREATE;
[201]423 APIRET rc = 1;
[1544]424 CHAR *moder = "r";
[2]425
426 *SwapperDat = 0;
[201]427 // Check already known
[1498]428 PrfQueryProfileData(fmprof, (CHAR *) FM3Str, "SwapperDat", SwapperDat, &size);
[551]429 if (*SwapperDat) {
[201]430 nm = 1;
[843]431 rc = DosFindFirst(SwapperDat,
[1335]432 &hdir,
433 FILE_NORMAL | FILE_ARCHIVED |
434 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
435 &ffb, sizeof(ffb), &nm, FIL_STANDARDL);
[850]436 if (rc && rc != ERROR_FILE_NOT_FOUND && rc != ERROR_PATH_NOT_FOUND) {
[849]437 FILEFINDBUF3 ffb;
438 rc = DosFindFirst(SwapperDat,
[1335]439 &hdir,
440 FILE_NORMAL | FILE_ARCHIVED |
441 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
442 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
[849]443 fNoLargeFileSupport = TRUE;
444 }
[551]445 if (!rc) {
[2]446 DosFindClose(hdir);
[1544]447 fp = xfopen(SwapperDat, moder, pszSrcFile, __LINE__, TRUE);
[551]448 if (fp) {
[1335]449 fclose(fp);
450 *SwapperDat = 0;
451 rc = 1; // Force config.sys scan
[2]452 }
453 }
454 else
455 *SwapperDat = 0;
456 }
[201]457 // If not defined in INI or INI wrong, scan config.sys for SWAPPATH statement
[551]458 if (rc) {
[189]459 if (DosQuerySysInfo(QSV_BOOT_DRIVE,
[1335]460 QSV_BOOT_DRIVE,
461 &nm,
462 sizeof(ULONG))) {
[1156]463 nm = 3; // Assume drive C:
[201]464 }
[551]465 *filename = (CHAR) nm + '@';
[1544]466 fp = xfsopen(filename, moder, SH_DENYNO, pszSrcFile, __LINE__, TRUE);
[551]467 if (fp) {
[404]468 while (!feof(fp)) {
[1335]469 if (!xfgets(input, sizeof(input), fp, pszSrcFile, __LINE__))
470 break;
471 lstrip(input);
472 if (!strnicmp(input, "SWAPPATH", 8)) {
473 p = input + 8;
474 while (*p == ' ')
475 p++;
476 if (*p == '=') {
477 p++;
[1480]478 bstripcr(p);
[1335]479 if (*p == '\"') {
480 p++;
481 pp = p;
482 while (*pp && *pp != '\"')
483 *pp += 1;
484 if (*pp)
485 *pp = 0;
486 }
487 else {
488 pp = strchr(p, ' ');
489 if (pp)
490 *pp = 0;
491 }
492 if (*p) {
493 strncpy(SwapperDat, p, CCHMAXPATH);
494 SwapperDat[CCHMAXPATH - 1] = 0;
495 BldFullPathName(SwapperDat, SwapperDat, "SWAPPER.DAT");
496 hdir = HDIR_CREATE;
497 nm = 1;
498 rc = DosFindFirst(SwapperDat,
499 &hdir,
500 FILE_NORMAL | FILE_ARCHIVED |
501 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
[1480]502 &ffb, sizeof(ffb), &nm, FIL_STANDARDL);
[1335]503 if (rc){
504 FILEFINDBUF3 ffb;
505 rc = DosFindFirst(SwapperDat,
506 &hdir,
507 FILE_NORMAL | FILE_ARCHIVED |
508 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
509 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
510 fNoLargeFileSupport = TRUE;
511 }
512 if (!rc) {
513 DosFindClose(hdir);
514 PrfWriteProfileString(fmprof,
[1505]515 FM3Str, "SwapperDat", SwapperDat);
[1335]516 }
517 else
518 *SwapperDat = 0;
519 break;
520 }
521 }
522 } // if SWAPPATH
[1156]523 } // while
[2]524 fclose(fp);
525 }
526 }
527}
528
[690]529unsigned APIENTRY LibMain(unsigned hModule,
[1335]530 unsigned ulFlag)
[690]531{
532 switch (ulFlag) {
533 case 0:
534 FM3DllHandle = hModule;
535
536 DosError(FERR_DISABLEHARDERR);
537 memset(&RGBBLACK, 0, sizeof(RGB2));
538 RGBGREY.bRed = RGBGREY.bGreen = RGBGREY.bBlue = (BYTE)204;
539 RGBGREY.fcOptions = 0;
[1505]540 FM3UL = *(ULONG *) FM3Str;
[690]541 break;
542 case 1:
543 StopPrinting = 1;
544 if (fmprof)
545 PrfCloseProfile(fmprof);
546 DosError(FERR_ENABLEHARDERR);
547 break;
548 default:
549 return 0UL;
550 }
551 return 1UL;
552}
553
[189]554VOID APIENTRY DeInitFM3DLL(ULONG why)
555{
[1673]556 // cleanup
[189]557 static CHAR s[CCHMAXPATH];
[1075]558 CHAR *enddir, szTempFile[CCHMAXPATH];
[189]559 HDIR search_handle;
560 ULONG num_matches;
[843]561 FILEFINDBUF3 ffb;
[2]562
563 StopTimer();
564 StopPrinting = 1;
565
[189]566 if (LogFileHandle)
[2]567 fclose(LogFileHandle);
568
[551]569 if (fmprof) {
[2]570 PrfCloseProfile(fmprof);
[189]571 fmprof = (HINI) 0;
[551]572 if (fIniExisted) {
[2]573 DosError(FERR_DISABLEHARDERR);
[1607]574 DosCopy(PCSZ_FM3DOTINI, PCSZ_FM3INIDOTBAK, DCPY_EXISTING);
[2]575 }
576 }
577
[189]578 if (fToolsChanged)
[2]579 save_tools(NULL);
[689]580 fcloseall();
[2]581 save_dir(s);
[1438]582 AddBackslashToPath(s);
583 //if (s[strlen(s) - 1] != '\\')
584 // strcat(s, "\\");
[2]585 enddir = &s[strlen(s)];
[551]586 if (*ArcTempRoot) {
[189]587 strcat(s, ArcTempRoot);
588 strcat(s, "*");
[2]589 search_handle = HDIR_CREATE;
590 num_matches = 1L;
[843]591 if (!DosFindFirst(s,
[1335]592 &search_handle,
593 FILE_NORMAL | FILE_DIRECTORY |
594 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
595 FILE_ARCHIVED,
596 &ffb, sizeof(ffb), &num_matches, FIL_STANDARD)) {
[551]597 do {
[1335]598 strcpy(enddir, ffb.achName);
599 if (ffb.attrFile & FILE_DIRECTORY) {
[1739]600 wipeallf(TRUE, "%s\\*", s);
[1335]601 DosDeleteDir(s);
602 }
603 else
[1402]604 unlinkf(s);
[189]605 }
[843]606 while (!DosFindNext(search_handle,
[1335]607 &ffb, sizeof(ffb), &num_matches));
[2]608 DosFindClose(search_handle);
609 }
610 }
[1082]611 if (pTmpDir)
612 strcpy(s, pTmpDir);
613 else
[1104]614 strcpy(s, pFM2SaveDirectory);
[1438]615 AddBackslashToPath(s);
[2]616 enddir = &s[strlen(s)];
[1089]617 strcat(s, "$FM2LI$T.");
[189]618 strcat(s, "???");
[2]619 search_handle = HDIR_CREATE;
[838]620 num_matches = 1;
[843]621 if (!DosFindFirst(s,
[1335]622 &search_handle,
623 FILE_NORMAL | FILE_DIRECTORY |
624 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
625 FILE_ARCHIVED,
626 &ffb, sizeof(ffb), &num_matches, FIL_STANDARD)) {
[551]627 do {
[843]628 if (!(ffb.attrFile & FILE_DIRECTORY)) {
[1335]629 strcpy(enddir, ffb.achName);
[1402]630 unlinkf(s);
[2]631 }
[189]632 }
[843]633 while (!DosFindNext(search_handle,
[1335]634 &ffb, sizeof(ffb), &num_matches));
[2]635 DosFindClose(search_handle);
636 }
[1398]637 BldFullPathName(szTempFile, pTmpDir, PCSZ_FM2PLAYTEMP);
[1075]638 DosForceDelete(szTempFile);
[1082]639 if (pTmpDir) {
[1739]640 wipeallf(TRUE, "%s\\*", pTmpDir);
[1082]641 DosDeleteDir(pTmpDir);
642 }
[2]643 EndNote();
[189]644 if (FM3ModHandle)
[2]645 DosFreeModule(FM3ModHandle);
646
[551]647 DosExitList(EXLST_REMOVE, DeInitFM3DLL);
[2]648}
649
[189]650BOOL InitFM3DLL(HAB hab, int argc, char **argv)
651{
[1673]652 /**
[2]653 * this function should be called by any application using this DLL right
654 * after setting up a message queue
655 */
656
657 CLASSINFO clinfo;
[201]658 APIRET rc;
[1369]659 APIRET rcl;
660 APIRET rcq;
661 PFN pfnResVersion;
662 ULONG RVMajor;
663 ULONG RVMinor;
664 ULONG ret;
665 FILESTATUS3 fs3;
[803]666 PSZ env;
[201]667 CHAR dllfile[CCHMAXPATH];
[1603]668 CHAR temp[CCHMAXPATH];
[1604]669 CHAR *p;
[201]670 ULONG size;
[2]671
[1607]672 strcpy(dllfile, PCSZ_FM3RES);
673 env = getenv(PCSZ_FM3INI);
[551]674 if (env) {
[201]675 DosError(FERR_DISABLEHARDERR);
[849]676 rc = DosQueryPathInfo(env, FIL_STANDARD, &fs3, sizeof(fs3));
[551]677 if (!rc) {
[803]678 if (fs3.attrFile & FILE_DIRECTORY) {
[1607]679 BldFullPathName(dllfile, env, PCSZ_FM3RES); // 23 Aug 07 SHL
[1335]680 DosError(FERR_DISABLEHARDERR);
681 if (DosQueryPathInfo(dllfile, FIL_STANDARD, &fs3, sizeof(fs3)))
[1607]682 strcpy(dllfile, PCSZ_FM3RES);
[2]683 }
684 }
[201]685 }
[1369]686
[551]687 rcl = DosLoadModule(NULL, 0, dllfile, &FM3ModHandle);
688 if (rcl) {
[339]689 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
[1335]690 HWND_DESKTOP,
691 GetPString(IDS_ERRORTEXT), GetPString(IDS_FM3RESERROR1TEXT));
[339]692 return FALSE;
693 }
[1369]694
[339]695 rc = DosExitList(EXLST_ADD, DeInitFM3DLL);
[551]696 if (rc) {
[803]697 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[1335]698 "DosExitList");
[339]699 }
[1369]700
[551]701 rcq = DosQueryProcAddr(FM3ModHandle, 1, "ResVersion", &pfnResVersion);
[201]702 if (!rcq)
703 ret = pfnResVersion(&RVMajor, &RVMinor);
[1369]704 else {
705 ret = 0;
706 RVMajor = 0;
707 RVMinor = 0;
[201]708 }
[1369]709
[551]710 if (RVMajor < VERMAJOR || (RVMajor == VERMAJOR && RVMinor < VERMINOR)) {
[201]711 saymsg(MB_ENTER,
[1335]712 HWND_DESKTOP,
713 GetPString(IDS_ERRORTEXT),
714 GetPString(IDS_FM3RESERROR2TEXT),
715 !rcq ?
716 GetPString(IDS_FM3RESERROR3TEXT) :
717 !rcl ?
718 GetPString(IDS_FM3RESERROR4TEXT) :
719 GetPString(IDS_FM3RESERROR5TEXT), RVMajor, RVMinor, rcl, rcq, ret);
[201]720 return FALSE;
[2]721 }
722
[189]723 if (!*profile)
[1607]724 strcpy(profile, PCSZ_FM3DOTINI);
[2]725 mypid = getpid();
[1673]726 // give default appname if none set by caller
[189]727 if (!*appname)
[1505]728 strcpy(appname, FM3Str);
[1673]729 // save appname; may be reset below
[189]730 strcpy(realappname, appname);
[1505]731 if (!strcmp(appname, FM3Str))
[803]732 DosSetMaxFH(100);
[189]733 else if (!strcmp(appname, "VDir") ||
[1335]734 !strcmp(appname, "VTree") ||
735 !strcmp(appname, "VCollect") ||
736 !strcmp(appname, "SEEALL") || !strcmp(appname, "FM/4"))
[803]737 DosSetMaxFH(60);
[2]738 else
[803]739 DosSetMaxFH(40);
[2]740
[189]741 if (DosQuerySysInfo(QSV_VERSION_MAJOR,
[1335]742 QSV_VERSION_MINOR,
743 OS2ver,
744 sizeof(OS2ver))) {
[2]745 OS2ver[0] = 2;
746 OS2ver[1] = 1;
747 }
748
[1603]749 //Save the FM2 save directory name. This is the location of the ini, dat files etc.
[1604]750 rc = save_dir2(temp);
751 if (rc) {
752 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
753 HWND_DESKTOP,
754 GetPString(IDS_ERRORTEXT), GetPString(IDS_FM3SAVEDIRERROR1TEXT));
755 return FALSE;
756 }
[1603]757 pFM2SaveDirectory = xstrdup(temp, pszSrcFile, __LINE__);
[1604]758 if (!pFM2SaveDirectory)
759 return FALSE; // already complained
[1082]760 // set up default root names for temp file storage and archive goodies
[1604]761 env = getenv("TEMP");
[1069]762 if (env != NULL) {
[1604]763 rc = 0;
[1069]764 DosError(FERR_DISABLEHARDERR);
765 rc = DosQueryPathInfo(env, FIL_STANDARD, &fs3, sizeof(fs3));
[1604]766 }
767 if (rc || env == NULL)
768 env = getenv("TMP");
769 if (env != NULL) {
770 DosError(FERR_DISABLEHARDERR);
771 rc = DosQueryPathInfo(env, FIL_STANDARD, &fs3, sizeof(fs3));
[1069]772 if (!rc) {
[1604]773 CHAR *enddir, szTempName[CCHMAXPATH];
[1089]774 FILEFINDBUF3 ffb;
775 HDIR search_handle;
776 ULONG num_matches, ul;
777
778 strcpy(szTempName, env);
[1438]779 AddBackslashToPath(szTempName);
[1089]780 enddir = &szTempName[strlen(szTempName)];
781 strcat(szTempName, "$FM2????.");
782 strcat(szTempName, "???");
783 search_handle = HDIR_CREATE;
784 num_matches = 1;
785 if (!DosFindFirst(szTempName,
[1335]786 &search_handle,
787 FILE_NORMAL | FILE_DIRECTORY |
788 FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
789 FILE_ARCHIVED,
[1603]790 &ffb, sizeof(ffb), &num_matches, FIL_STANDARD)) {
791 do {
[1335]792 strcpy(enddir, ffb.achName);
793 p = strrchr(szTempName, '.');
794 if (p) {
795 p++;
796 ul = strtol(p, &p + 2, 16);
797 GetDosPgmName(ul, temp);
798 if (!strstr(temp, "FM/2") &&
799 !strstr(temp, "AV/2")) {
[1710]800 wipeallf(TRUE, "%s\\*", szTempName);
[1335]801 DosDeleteDir(szTempName);
802 }
803 }
[1603]804 }
805 while (!DosFindNext(search_handle,
806 &ffb, sizeof(ffb), &num_matches));
807 DosFindClose(search_handle);
808 }
[1069]809 if (fs3.attrFile & FILE_DIRECTORY) {
[1335]810 strcpy(szTempName, env);
811 MakeTempName(szTempName, NULL, 1);
[1369]812 rc = DosCreateDir(szTempName, 0);
813 if (!rc)
[1554]814 pTmpDir = xstrdup(szTempName, pszSrcFile, __LINE__); // if writable
815 else
[1603]816 pTmpDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
[1069]817 }
818 }
[1603]819 }
820 else
821 pTmpDir = xstrdup(pFM2SaveDirectory, pszSrcFile, __LINE__);
[1120]822 // Check free space on TMP and FM2 Save drives
[1112]823 {
824 if (pTmpDir && CheckDriveSpaceAvail(pTmpDir, ullTmpSpaceNeeded, 0) == 1) {
825 if (CheckDriveSpaceAvail(pFM2SaveDirectory, ullTmpSpaceNeeded, 0) == 0){
[1335]826 ret = saymsg(MB_YESNO,
827 HWND_DESKTOP,
828 NullStr,
829 GetPString(IDS_TMPDRIVESPACELIMITED),
830 pTmpDir);
831 if (ret == MBID_YES)
832 pTmpDir = pFM2SaveDirectory;
[1112]833 }
834 else
[1335]835 saymsg(MB_OK,
836 HWND_DESKTOP,
837 NullStr,
838 GetPString(IDS_SAVETMPDRIVESPACELIMITED),
839 pTmpDir,
840 pFM2SaveDirectory);
[1112]841 }
842 else if (CheckDriveSpaceAvail(pFM2SaveDirectory, ullTmpSpaceNeeded, 0) == 1)
843 saymsg(MB_OK,
[1335]844 HWND_DESKTOP,
845 NullStr,
846 GetPString(IDS_SAVEDRIVESPACELIMITED),
847 pFM2SaveDirectory);
[1112]848 }
849 BldFullPathName(ArcTempRoot, pTmpDir, fAmAV2 ? "$AV$ARC$" : "$FM$ARC$");
850
[1082]851 // initialize random number generator
[2]852 srand(time(NULL) + clock());
853
854 priority_bumped();
855
[1673]856 // _heapmin() is done in a separate thread -- start it
[1335]857 if (xbeginthread(HeapThread,
858 32768,
859 MPVOID,
860 pszSrcFile,
861 __LINE__) == -1) {
[339]862 return FALSE;
863 }
[917]864
[1673]865 // timer messages are sent from a separate thread -- start it
[803]866 if (!StartTimer()) {
867 Runtime_Error(pszSrcFile, __LINE__,
[1335]868 GetPString(IDS_COULDNTSTARTTHREADTEXT));
[2]869 return FALSE;
[803]870 }
[2]871
[1673]872 // Are we the workplace shell?
[705]873 env = getenv("WORKPLACE_PROCESS");
[718]874 fWorkPlace = env != NULL &&
[1335]875 (stricmp(env, "YES") == 0 || atoi(env) == 1);
[718]876
[189]877 if ((!strchr(profile, '\\') && !strchr(profile, ':')) ||
[1604]878 !(fmprof = PrfOpenProfile((HAB)0, profile))) {
[1607]879 // figure out where to put INI file...
[803]880 CHAR inipath[CCHMAXPATH];
[2]881
882 DosError(FERR_DISABLEHARDERR);
[1104]883 strcpy(HomePath, pFM2SaveDirectory);
[2]884 DosError(FERR_DISABLEHARDERR);
[189]885 memset(driveserial, -1, sizeof(driveserial));
[2]886 *inipath = 0;
[1607]887 env = getenv(PCSZ_FM3INI);
[551]888 if (env) {
[189]889 strcpy(inipath, env);
[2]890 DosError(FERR_DISABLEHARDERR);
[849]891 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3));
[551]892 if (!rc) {
[1335]893 if (fs3.attrFile & FILE_DIRECTORY)
894 BldFullPathName(inipath, inipath, profile);
[2]895 }
896 }
[1604]897 else {
[2]898 env = searchpath(profile);
[189]899 if (!env)
[1335]900 env = profile;
[189]901 strcpy(inipath, env);
[1604]902 } //fixme the DosCopies probably fail if the INI isn't in the FM2 directory GKY 06 Aug 11
[201]903 if (!*inipath)
904 strcpy(inipath, profile);
905 DosError(FERR_DISABLEHARDERR);
[917]906 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3));
907 if (rc) {
[1604]908 if (rc == ERROR_FILE_NOT_FOUND) {
[1607]909 DosCopy(PCSZ_FM3INIDOTBAK, PCSZ_FM3DOTINI, 0);
[1604]910 }
911 rc = DosQueryPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3));
912 if (rc)
913 fWantFirstTimeInit = TRUE;
[917]914 }
[1604]915 if (!fWantFirstTimeInit) { //Check the ini file header and restore from backup if corupted
[989]916 if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
[1604]917 saymsg(MB_ENTER,HWND_DESKTOP, GetPString(IDS_DEBUG_STRING),
918 GetPString(IDS_INIFAILURETEXT));
[1607]919 DosCopy(PCSZ_FM3DOTINI, PCSZ_FM3INIDOTBAD, DCPY_EXISTING);
920 DosCopy(PCSZ_FM3INIDOTBAK, PCSZ_FM3DOTINI, DCPY_EXISTING);
[1604]921 if (!CheckFileHeader(inipath, "\xff\xff\xff\xff\x14\x00\x00\x00", 0L)) {
[1607]922 DosCopy(PCSZ_FM3DOTINI, PCSZ_FM3INIDOTBAD2, DCPY_EXISTING);
[1604]923 fWantFirstTimeInit = TRUE;
924 }
[2]925 }
[1604]926 }
927 // in some odd cases the INI file can get set to readonly status
928 // here we test it and reset the readonly bit if necessary
929 if (!fWantFirstTimeInit) {
930 fIniExisted = TRUE;
931 if (fs3.attrFile & (FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM)) {
932 fs3.attrFile &= ~(FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM);
933 rc = xDosSetPathInfo(inipath, FIL_STANDARD, &fs3, sizeof(fs3), 0);
934 if (rc) {
935 Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
936 GetPString(IDS_INIREADONLYTEXT), inipath);
937 }
[989]938 }
[2]939 }
[803]940 fmprof = PrfOpenProfile((HAB)0, inipath);
[551]941 if (!fmprof) {
[1607]942 strcpy(inipath, PCSZ_FM3DOTINI);
[803]943 fmprof = PrfOpenProfile((HAB)0, inipath);
[2]944 }
[201]945
[917]946 // 10 Jan 08 SHL fixme to do first time if new ini
947 // 10 Jan 08 SHL post UM_FIRSTTIME to main window
[551]948 if (!fmprof) {
949 Win_Error(NULLHANDLE, NULLHANDLE, pszSrcFile, __LINE__,
[1402]950 PCSZ_PRFOPENPROFILEFAILED, inipath);
[2]951 return FALSE;
952 }
953 }
954
[1363]955 ArgDriveFlags(argc, argv);
956 FillInDriveFlags(NULL);
957
[2]958 FindSwapperDat();
959
[1673]960 // start help
[189]961 memset(&hini, 0, sizeof(HELPINIT));
[2]962 hini.cb = sizeof(HELPINIT);
[189]963 hini.phtHelpTable = (PHELPTABLE) MAKELONG(ID_HELPTABLE, 0xffff);
964 hini.hmodAccelActionBarModule = (HMODULE) 0;
[1394]965 hini.pszHelpWindowTitle = (PSZ)GetPString(IDS_FM2HELPTITLETEXT);
[1546]966 hini.hmodHelpTableModule = FM3ModHandle;
[2]967 hini.fShowPanelId = CMIC_HIDE_PANEL_ID;
[1607]968 hini.pszHelpLibraryName = (CHAR *) PCSZ_FM3DOTHLP;
[189]969 hwndHelp = WinCreateHelpInstance(hab, &hini);
[551]970 if (!hwndHelp) {
[1560]971 CHAR helppath[CCHMAXPATH];
[1607]972 env = getenv(PCSZ_FM3INI);
[551]973 if (env) {
[189]974 strcpy(helppath, env);
[2]975 DosError(FERR_DISABLEHARDERR);
[849]976 rc = DosQueryPathInfo(helppath, FIL_STANDARD, &fs3, sizeof(fs3));
[551]977 if (!rc) {
[1335]978 if (fs3.attrFile & FILE_DIRECTORY) {
[1607]979 BldFullPathName(helppath, helppath, PCSZ_FM3DOTHLP);
[1335]980 hini.pszHelpLibraryName = helppath;
981 hwndHelp = WinCreateHelpInstance(hab, &hini);
[1560]982 if (!hwndHelp)
[1607]983 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
984 "WinCreateHelpInstance failed for %s with error 0x%x",
985 hini.pszHelpLibraryName, hini.ulReturnCode);
[1335]986 }
[2]987 }
988 }
989 }
[551]990 if (!hwndHelp) {
[2]991 saymsg(MB_ENTER | MB_ICONEXCLAMATION,
[1335]992 HWND_DESKTOP,
993 GetPString(IDS_FM2TROUBLETEXT),
994 GetPString(IDS_CANTLOADHELPTEXT),
995 GetPString(IDS_NOHELPACCEPTTEXT));
[2]996 }
997
[1365]998 // a couple of default window procs so we don't have to look them up later
[189]999 if (WinQueryClassInfo(hab, WC_CONTAINER, &clinfo))
[2]1000 PFNWPCnr = clinfo.pfnWindowProc;
[189]1001 if (WinQueryClassInfo(hab, WC_FRAME, &clinfo))
[2]1002 PFNWPFrame = clinfo.pfnWindowProc;
[189]1003 if (WinQueryClassInfo(hab, WC_BUTTON, &clinfo))
[2]1004 PFNWPButton = clinfo.pfnWindowProc;
[189]1005 if (WinQueryClassInfo(hab, WC_STATIC, &clinfo))
[2]1006 PFNWPStatic = clinfo.pfnWindowProc;
[189]1007 if (WinQueryClassInfo(hab, WC_MLE, &clinfo))
[2]1008 PFNWPMLE = clinfo.pfnWindowProc;
[551]1009 if (!PFNWPCnr || !PFNWPFrame || !PFNWPButton || !PFNWPStatic || !PFNWPMLE) {
[339]1010 Runtime_Error(pszSrcFile, __LINE__, "WinQueryClassInfo");
[2]1011 return FALSE;
1012 }
1013
[1673]1014 // register window classes we use
[2]1015 WinRegisterClass(hab,
[1498]1016 (CHAR *) WC_MAINWND,
[1335]1017 MainWndProc,
1018 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 8);
[2]1019 WinRegisterClass(hab,
[1498]1020 (CHAR *) WC_MAINWND2,
[1335]1021 MainWndProc2,
1022 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 4);
[2]1023 WinRegisterClass(hab,
[1498]1024 (CHAR *) WC_TREECONTAINER,
[1335]1025 TreeClientWndProc,
1026 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]1027 WinRegisterClass(hab,
[1498]1028 (CHAR *) WC_DIRCONTAINER,
[1335]1029 DirClientWndProc,
1030 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]1031 WinRegisterClass(hab,
[1498]1032 (CHAR *) WC_COLLECTOR,
[1335]1033 CollectorClientWndProc,
1034 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]1035 WinRegisterClass(hab,
[1498]1036 (CHAR *) WC_ARCCONTAINER,
[1335]1037 ArcClientWndProc,
1038 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]1039 WinRegisterClass(hab,
[1498]1040 (CHAR *) WC_MLEEDITOR,
[1335]1041 MLEEditorProc,
1042 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]1043 WinRegisterClass(hab,
[1498]1044 (CHAR *) WC_INIEDITOR,
[1335]1045 IniProc,
1046 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID) * 2);
[2]1047 WinRegisterClass(hab,
[1498]1048 (CHAR *) WC_TOOLBACK,
[1335]1049 ToolBackProc,
1050 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1051 sizeof(PVOID));
[2]1052 WinRegisterClass(hab,
[1498]1053 (CHAR *) WC_DRIVEBACK,
[1335]1054 DriveBackProc,
1055 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1056 sizeof(PVOID));
[2]1057 WinRegisterClass(hab,
[1498]1058 (CHAR *) WC_SEEALL,
[1335]1059 SeeAllWndProc,
1060 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
[2]1061 WinRegisterClass(hab,
[1498]1062 (CHAR *) WC_NEWVIEW,
[1335]1063 ViewWndProc,
1064 CS_SIZEREDRAW | CS_CLIPCHILDREN, sizeof(PVOID));
[2]1065 WinRegisterClass(hab,
[1498]1066 (CHAR *) WC_TOOLBUTTONS,
[1335]1067 ChildButtonProc,
1068 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1069 sizeof(PVOID));
[2]1070 WinRegisterClass(hab,
[1498]1071 (CHAR *) WC_DRIVEBUTTONS,
[1335]1072 DriveProc,
1073 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1074 sizeof(PVOID));
[2]1075 WinRegisterClass(hab,
[1498]1076 (CHAR *) WC_BUBBLE,
[1335]1077 BubbleProc,
1078 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1079 sizeof(ULONG) * 2);
[2]1080 WinRegisterClass(hab,
[1498]1081 (CHAR *) WC_STATUS,
[1335]1082 StatusProc,
1083 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1084 sizeof(ULONG));
[2]1085 WinRegisterClass(hab,
[1498]1086 (CHAR *) WC_DIRSTATUS,
[1335]1087 DirTextProc,
1088 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1089 sizeof(ULONG));
[2]1090 WinRegisterClass(hab,
[1498]1091 (CHAR *) WC_TREESTATUS,
[1335]1092 TreeStatProc,
1093 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1094 sizeof(ULONG));
[2]1095 WinRegisterClass(hab,
[1498]1096 (CHAR *) WC_ARCSTATUS,
[1335]1097 ArcTextProc,
1098 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1099 sizeof(ULONG));
[2]1100 WinRegisterClass(hab,
[1498]1101 (CHAR *) WC_COLSTATUS,
[1335]1102 CollectorTextProc,
1103 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1104 sizeof(ULONG));
[2]1105 WinRegisterClass(hab,
[1498]1106 (CHAR *) WC_SEESTATUS,
[1335]1107 SeeStatusProc,
1108 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1109 sizeof(ULONG));
[2]1110 WinRegisterClass(hab,
[1498]1111 (CHAR *) WC_VIEWSTATUS,
[1335]1112 ViewStatusProc,
1113 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1114 sizeof(ULONG));
[2]1115 WinRegisterClass(hab,
[1498]1116 (CHAR *) WC_ERRORWND,
[1335]1117 NotifyWndProc,
1118 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1119 sizeof(PVOID));
[2]1120 WinRegisterClass(hab,
[1498]1121 (CHAR *) WC_MINITIME,
[1335]1122 MiniTimeProc,
1123 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1124 sizeof(PVOID) * 2);
[2]1125 WinRegisterClass(hab,
[1498]1126 (CHAR *) WC_DATABAR,
[1335]1127 DataProc, CS_SIZEREDRAW, sizeof(PVOID));
[2]1128 WinRegisterClass(hab,
[1498]1129 (CHAR *) WC_TREEOPENBUTTON,
[1335]1130 OpenButtonProc,
1131 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1132 sizeof(PVOID));
[2]1133 WinRegisterClass(hab,
[1498]1134 (CHAR *) WC_AUTOVIEW,
[1335]1135 AutoViewProc,
1136 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1137 sizeof(PVOID));
[2]1138 WinRegisterClass(hab,
[1498]1139 (CHAR *) WC_LED,
[1335]1140 LEDProc,
1141 CS_SYNCPAINT | CS_SIZEREDRAW | CS_PARENTCLIP,
1142 sizeof(PVOID));
[2]1143
[1333]1144 if (DosCreateMutexSem(NULL, &hmtxFM2Globals, 0L, FALSE))
[1312]1145 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[1553]1146 PCSZ_DOSCREATEMUTEXSEM);
[1555]1147 if (DosCreateMutexSem(NULL, &hmtxScanning, 0L, TRUE))
[1553]1148 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[1398]1149 PCSZ_DOSCREATEMUTEXSEM);
[1333]1150 if (DosCreateMutexSem(NULL, &hmtxFM2Delete, 0L, FALSE))
[1312]1151 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[1471]1152 PCSZ_DOSCREATEMUTEXSEM);
[1551]1153 if (DosCreateEventSem(NULL, &hevTreeCnrScanComplete, 0L, TRUE))
[1444]1154 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
[1471]1155 PCSZ_DOSCREATEEVENTSEM);
[1320]1156
[1475]1157 /**
[201]1158 * set some defaults (note: everything else automatically initialized
[2]1159 * to 0)
1160 */
[1065]1161 dsDirCnrDefault.detailssize = dsDirCnrDefault.detailsea = dsDirCnrDefault.detailslwdate =
1162 dsDirCnrDefault.detailslwtime = dsDirCnrDefault.detailsattr = dsDirCnrDefault.detailsicon =
1163 fAutoTile = fConfirmDelete = fLoadSubject = fUnHilite =
[189]1164 fLoadLongnames = fToolbar = fSaveState = fGuessType = fToolbarHelp =
[1482]1165 fAutoAddDirs = fUseNewViewer = fDataToFore = fDataShowDrives = fDataMin =
[189]1166 fSplitStatus = fDragndropDlg = fQuickArcFind = fKeepCmdLine =
[1720]1167 fMoreButtons = fDrivebar = fCollapseFirst = fSwitchTree =
[189]1168 fSwitchTreeExpand = fNoSearch = fCustomFileDlg = fOtherHelp =
1169 fSaveMiniCmds = fUserComboBox = fFM2Deletes = fConfirmTarget =
[1376]1170 fShowTarget = fDrivebarHelp = fCheckMM = fInitialDriveScan =
1171 fEjectRemovableScan = fRScanLocal = TRUE;
[2]1172 ulCnrType = CCS_EXTENDSEL;
[1482]1173 FilesToGet = FILESTOGET_MAX;
[985]1174 MaxComLineStrg = MAXCOMLINESTRGDEFAULT;
[752]1175 AutoviewHeight = 48;
[1333]1176 //strcpy(printer, "PRN");
[2]1177 prnwidth = 80;
1178 prnlength = 66;
1179 prntmargin = 6;
1180 prnbmargin = 6;
1181 prnlmargin = 6;
1182 prnrmargin = 3;
1183 prnspacing = 1;
1184 prntabspaces = 8;
[1482]1185 CollectorsortFlags = sortFlags = SORT_FILENAME | SORT_DIRSFIRST;
1186 //ullDATFileSpaceNeeded = 10000;
[2]1187
[860]1188 //Get default Country info
1189 {
1190 COUNTRYCODE Country = {0};
1191 ULONG ulInfoLen = 0;
1192 COUNTRYINFO CtryInfo = {0};
1193
[1395]1194 if (!DosQueryCtryInfo(sizeof(CtryInfo), &Country, &CtryInfo, &ulInfoLen)) {
1195 *ThousandsSeparator = CtryInfo.szThousandsSeparator[0];
1196 strcpy(DateSeparator, CtryInfo.szDateSeparator);
1197 strcpy(TimeSeparator, CtryInfo.szTimeSeparator);
1198 ulDateFmt = CtryInfo.fsDateFmt;
1199 ulTimeFmt = CtryInfo.fsTimeFmt;
1200 //DbgMsg(pszSrcFile, __LINE__, "Date Fmt %x", ulDateFmt);
[860]1201 }
[1395]1202 else {
1203 strcpy(ThousandsSeparator, ",");
1204 strcpy(DateSeparator, "/");
1205 strcpy(TimeSeparator, ":");
1206 ulDateFmt = 0;
1207 ulTimeFmt = 0;
1208 }
1209 }
[1360]1210 { // Check for the existance of various partitioning tools to set up menu items
1211 CHAR *FullPath;
1212 ULONG ulAppType;
[860]1213
[1400]1214 FullPath = searchapath(PCSZ_PATH, PCSZ_LVMGUICMD);
[1369]1215 if (*FullPath)
1216 fLVMGui = TRUE;
[1439]1217 if (!xDosQueryAppType(PCSZ_DFSOS2EXE, &ulAppType))
[1360]1218 fDFSee = TRUE;
[1439]1219 if (!xDosQueryAppType(PCSZ_MINILVMEXE, &ulAppType))
[1369]1220 fMiniLVM = TRUE;
[1439]1221 if (!xDosQueryAppType(PCSZ_FDISKPMEXE, &ulAppType))
[1369]1222 fFDisk = TRUE;
[1439]1223 if (!xDosQueryAppType(PCSZ_LVMEXE, &ulAppType))
[1369]1224 fLVM = TRUE;
1225
[1664]1226 //Check for unlock.exe
1227 if (!xDosQueryAppType(PCSZ_UNLOCKEXE, &ulAppType))
1228 fUnlock = TRUE;
1229
[1369]1230 // Check to see if we are running protect only
[1439]1231 if (!xDosQueryAppType(GetCmdSpec(TRUE), &ulAppType)) {
[1452]1232 HMODULE hmod;
1233 APIRET rc;
1234
1235 rc = DosQueryModuleHandle("VKBD", &hmod);
1236 if (rc != NO_ERROR) {
[1471]1237 fProtectOnly = TRUE;
[1475]1238 //DbgMsg(pszSrcFile, __LINE__, "DosQModuleHandle VKBD returned %d fProtectOnly=%d", rc, fProtectOnly);
[1452]1239 }
1240 else {
[1471]1241 rc = DosQueryModuleHandle("VMOUSE", &hmod);
1242 if (rc != NO_ERROR) {
1243 fProtectOnly = TRUE;
[1475]1244 //DbgMsg(pszSrcFile, __LINE__, "DosQModuleHandle VMOUSE returned %d fProtectOnly=%d", rc, fProtectOnly);
[1471]1245 }
[1452]1246 }
[1369]1247 }
1248 else
1249 fProtectOnly = TRUE;
[1360]1250 }
1251
[201]1252 // load preferences from profile (INI) file
[1482]1253 /**
1254 * Separate paramenters -- Please note that appname should be used in
1255 * profile calls for user settings that work and are setable in more than one
[1505]1256 * miniapp; FM3Str should be used for setting only relavent to FM/2 or that
[1482]1257 * aren't user settable; realappname should be used for setting applicable to
1258 * one or more miniapp but not to FM/2
1259 */
[1711]1260 size = sizeof(BOOL);
[1713]1261 PrfQueryProfileData(fmprof, realappname, "SeparateParms", &fAppSeparateSettings, &size);
[1711]1262 if (!fAppSeparateSettings)
1263 strcpy(appname, FM3Str);
1264 else
1265 strcpy(appname, realappname);
[1328]1266 size = sizeof(ULONG);
1267 PrfQueryProfileData(fmprof, appname, "MaxComLineStrg", &MaxComLineStrg, &size);
[1004]1268 // Give user one chance to reset the default command line length to 1024 (4os2's unexpanded max)
1269 if (MaxComLineStrg == 2048) {
1270 BOOL MaxComLineChecked = FALSE;
1271
[1328]1272 size = sizeof(BOOL);
1273 PrfQueryProfileData(fmprof, appname, "MaxComLineChecked", &MaxComLineChecked, &size);
[1004]1274 if (!MaxComLineChecked) {
1275 ret = saymsg(MB_YESNO,
[1335]1276 HWND_DESKTOP,
1277 NullStr,
1278 GetPString(IDS_CHANGECMDLINELENGTHDEFAULT));
[1004]1279 if (ret == MBID_YES)
[1335]1280 MaxComLineStrg = 1024;
[1004]1281 MaxComLineChecked = TRUE;
[1333]1282 PrfWriteProfileData(fmprof, appname, "MaxComLineChecked", &MaxComLineChecked, sizeof(BOOL));
[1004]1283 }
1284 }
[985]1285 if (MaxComLineStrg < CMDLNLNGTH_MIN)
1286 MaxComLineStrg = CMDLNLNGTH_MIN;
1287 else if (MaxComLineStrg > CMDLNLNGTH_MAX)
1288 MaxComLineStrg = CMDLNLNGTH_MAX;
1289 editor = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1290 if (!editor)
1291 return 0; //already complained
1292 viewer = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1293 if (!viewer)
1294 return 0; //already complained
1295 virus = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1296 if (!virus)
1297 return 0; //already complained
1298 compare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1299 if (!compare)
1300 return 0; //already complained
1301 binview = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1302 if (!binview)
1303 return 0; //already complained
1304 bined = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1305 if (!bined)
1306 return 0; //already complained
1307 dircompare = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1308 if (!dircompare)
1309 return 0; //already complained
1310 ftprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1311 if (!ftprun)
1312 return 0; //already complained
1313 httprun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1314 if (!httprun)
1315 return 0; //already complained
1316 mailrun = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1317 if (!mailrun)
1318 return 0; //already complained
[1083]1319 pszTreeEnvVarList = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1320 if (!pszTreeEnvVarList)
1321 return 0; //already complained
[1333]1322 size = sizeof(BOOL);
[1522]1323 PrfQueryProfileData(fmprof, FM3Str, "DontSuggestAgain", &fDontSuggestAgain, &size);
[1451]1324 size = sizeof(BOOL);
[1328]1325 PrfQueryProfileData(fmprof, appname, "ShowTarget", &fShowTarget, &size);
[1333]1326 size = sizeof(BOOL);
[1328]1327 PrfQueryProfileData(fmprof, appname, "CheckMM", &fCheckMM, &size);
[1333]1328 size = sizeof(BOOL);
[1328]1329 PrfQueryProfileData(fmprof, appname, "ChangeTarget", &fChangeTarget, &size);
[1333]1330 size = sizeof(BOOL);
[1328]1331 PrfQueryProfileData(fmprof, appname, "ConfirmTarget", &fConfirmTarget, &size);
[1333]1332 size = sizeof(BOOL);
[1482]1333 PrfQueryProfileData(fmprof, appname, "CustomFileDlg", &fCustomFileDlg, &size);
[1333]1334 size = sizeof(BOOL);
[1482]1335 PrfQueryProfileData(fmprof, appname, "SaveMiniCmds", &fSaveMiniCmds, &size);
[1333]1336 size = sizeof(BOOL);
[1328]1337 PrfQueryProfileData(fmprof, appname, "SaveBigCmds", &fSaveBigCmds, &size);
[1333]1338 size = sizeof(BOOL);
[1328]1339 PrfQueryProfileData(fmprof, appname, "NoFoldMenu", &fNoFoldMenu, &size);
[1333]1340 size = sizeof(BOOL);
[1505]1341 PrfQueryProfileData(fmprof, FM3Str, "Prnpagenums", &prnpagenums, &size);
[1333]1342 size = sizeof(BOOL);
[1505]1343 PrfQueryProfileData(fmprof, FM3Str, "Prnalt", &prnalt, &size);
[1333]1344 size = sizeof(BOOL);
[1505]1345 PrfQueryProfileData(fmprof, FM3Str, "Prnformat", &prnformat, &size);
[1333]1346 size = sizeof(BOOL);
[1505]1347 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedbefore", &prnformfeedbefore, &size);
[1333]1348 size = sizeof(BOOL);
[1505]1349 PrfQueryProfileData(fmprof, FM3Str, "Prnformfeedafter",&prnformfeedafter, &size);
[1328]1350 size = sizeof(ULONG);
[1505]1351 PrfQueryProfileData(fmprof, FM3Str, "Prntabspaces", &prntabspaces, &size);
[1333]1352 size = sizeof(ULONG);
[1505]1353 PrfQueryProfileData(fmprof, FM3Str, "Prnwidth", &prnwidth, &size);
[1333]1354 size = sizeof(ULONG);
[1505]1355 PrfQueryProfileData(fmprof, FM3Str, "Prnlength", &prnlength, &size);
[1333]1356 size = sizeof(ULONG);
[1505]1357 PrfQueryProfileData(fmprof, FM3Str, "Prntmargin", &prntmargin, &size);
[1333]1358 size = sizeof(ULONG);
[1505]1359 PrfQueryProfileData(fmprof, FM3Str, "Prnbmargin", &prnbmargin, &size);
[1333]1360 size = sizeof(ULONG);
[1505]1361 PrfQueryProfileData(fmprof, FM3Str, "Prnlmargin", &prnlmargin, &size);
[1333]1362 size = sizeof(ULONG);
[1505]1363 PrfQueryProfileData(fmprof, FM3Str, "Prnrmargin", &prnrmargin, &size);
[1333]1364 size = sizeof(ULONG);
[1505]1365 PrfQueryProfileData(fmprof, FM3Str, "Prnspacing", &prnspacing, &size);
[1328]1366 size = sizeof(BOOL);
[1482]1367 PrfQueryProfileData(fmprof, appname, "NoDead", &fNoDead, &size);
[1333]1368 size = sizeof(BOOL);
[1482]1369 PrfQueryProfileData(fmprof, appname, "NoFinger", &fNoFinger, &size);
[1333]1370 size = sizeof(BOOL);
[1482]1371 PrfQueryProfileData(fmprof, appname, "AlertBeepOff", &fAlertBeepOff, &size);
[1395]1372 size = sizeof(BOOL);
[1482]1373 PrfQueryProfileData(fmprof, appname, "ErrorBeepOff", &fErrorBeepOff, &size);
[1395]1374 size = sizeof(BOOL);
[1328]1375 PrfQueryProfileData(fmprof, appname, "SwitchTree", &fSwitchTree, &size);
[1333]1376 size = sizeof(BOOL);
1377 PrfQueryProfileData(fmprof, appname, "SwitchTreeExpand", &fSwitchTreeExpand, &size);
1378 size = sizeof(BOOL);
1379 PrfQueryProfileData(fmprof, appname, "SwitchTreeOnFocus", &fSwitchTreeOnFocus, &size);
1380 size = sizeof(BOOL);
1381 PrfQueryProfileData(fmprof, appname, "CollapseFirst", &fCollapseFirst, &size);
1382 size = sizeof(BOOL);
1383 PrfQueryProfileData(fmprof, appname, "FilesInTree", &fFilesInTree, &size);
1384 size = sizeof(BOOL);
[1482]1385 PrfQueryProfileData(fmprof, appname, "TopDir", &fTopDir, &size);
[1333]1386 size = sizeof(BOOL);
[1482]1387 PrfQueryProfileData(fmprof, appname, "LookInDir", &fLookInDir, &size);
[1333]1388 PrfQueryProfileString(fmprof, appname, "DefArc", NULL, szDefArc, sizeof(szDefArc));
[1328]1389 size = sizeof(ULONG);
[1482]1390 PrfQueryProfileData(fmprof, appname, "AutoviewHeight",
[1335]1391 &AutoviewHeight, &size);
[1328]1392 size = sizeof(BOOL);
[1482]1393 PrfQueryProfileData(fmprof, appname, "KeepCmdLine", &fKeepCmdLine, &size);
[551]1394 if (strcmp(realappname, "FM/4")) {
[1333]1395 size = sizeof(BOOL);
[1505]1396 PrfQueryProfileData(fmprof, FM3Str, "MoreButtons", &fMoreButtons, &size);
[1333]1397 size = sizeof(BOOL);
[1505]1398 PrfQueryProfileData(fmprof, FM3Str, "Drivebar", &fDrivebar, &size);
[201]1399 }
[1333]1400 size = sizeof(BOOL);
[1328]1401 PrfQueryProfileData(fmprof, appname, "NoSearch", &fNoSearch, &size);
[1333]1402 size = sizeof(BOOL);
[1328]1403 PrfQueryProfileData(fmprof, appname, "GuessType", &fGuessType, &size);
[1333]1404 size = sizeof(BOOL);
[1328]1405 PrfQueryProfileData(fmprof, appname, "ViewChild", &fViewChild, &size);
[1333]1406 size = sizeof(BOOL);
[1328]1407 PrfQueryProfileData(fmprof, appname, "ShowEnv", &fShowEnv, &size);
[1333]1408 PrfQueryProfileString(fmprof, appname, "TreeEnvVarList", "PATH;DPATH;LIBPATH;HELP;BOOKSHELF;",
[1471]1409 pszTreeEnvVarList, MaxComLineStrg);
[1328]1410 size = sizeof(BOOL);
[1482]1411 PrfQueryProfileData(fmprof, appname, "ShowDriveOnly", &fShowDriveOnly, &size);
[1431]1412 size = sizeof(BOOL);
[1482]1413 PrfQueryProfileData(fmprof, appname, "ShowFSTypeInTree", &fShowFSTypeInTree, &size);
[1424]1414 size = sizeof(BOOL);
[1482]1415 PrfQueryProfileData(fmprof, appname, "ShowDriveLabelInTree", &fShowDriveLabelInTree, &size);
[1434]1416 if (!fShowDriveOnly && !fShowFSTypeInTree && !fShowDriveLabelInTree)
1417 fShowDriveOnly = TRUE;
[1424]1418 size = sizeof(BOOL);
[1328]1419 PrfQueryProfileData(fmprof, appname, "LeaveTree", &fLeaveTree, &size);
[1333]1420 size = sizeof(BOOL);
[1482]1421 PrfQueryProfileData(fmprof, appname, "Comments", &fComments, &size);
[1328]1422 size = sizeof(ULONG);
1423 PrfQueryProfileData(fmprof, appname, "WS_ANIMATE", &fwsAnimate, &size);
[201]1424 if (fwsAnimate)
1425 fwsAnimate = WS_ANIMATE;
[1328]1426 size = sizeof(BOOL);
[1333]1427 PrfQueryProfileData(fmprof, appname, "SelectedAlways", &fSelectedAlways, &size);
1428 size = sizeof(BOOL);
[1482]1429 PrfQueryProfileData(fmprof, appname, "ToolbarHelp", &fToolbarHelp, &size);
[1333]1430 size = sizeof(BOOL);
[1482]1431 PrfQueryProfileData(fmprof, appname, "OtherHelp", &fOtherHelp, &size);
[1333]1432 size = sizeof(BOOL);
[1482]1433 PrfQueryProfileData(fmprof, appname, "DrivebarHelp", &fDrivebarHelp, &size);
[1333]1434 size = sizeof(BOOL);
[1328]1435 PrfQueryProfileData(fmprof, appname, "AutoAddDirs", &fAutoAddDirs, &size);
[1333]1436 size = sizeof(BOOL);
1437 PrfQueryProfileData(fmprof, appname, "AutoAddAllDirs", &fAutoAddAllDirs, &size);
1438 size = sizeof(BOOL);
[1505]1439 PrfQueryProfileData(fmprof, FM3Str, "UserListSwitches", &fUserListSwitches, &size);
[1333]1440 size = sizeof(BOOL);
1441 PrfQueryProfileData(fmprof, appname, "UseNewViewer", &fUseNewViewer, &size);
1442 size = sizeof(BOOL);
1443 PrfQueryProfileData(fmprof, appname, "DefaultDeletePerm", &fDefaultDeletePerm, &size);
1444 size = sizeof(BOOL);
[1505]1445 PrfQueryProfileData(fmprof, FM3Str, "ExternalINIs", &fExternalINIs, &size);
[1333]1446 size = sizeof(BOOL);
[1505]1447 PrfQueryProfileData(fmprof, FM3Str, "ExternalCollector", &fExternalCollector, &size);
[1333]1448 size = sizeof(BOOL);
[1505]1449 PrfQueryProfileData(fmprof, FM3Str, "ExternalArcboxes", &fExternalArcboxes, &size);
[1333]1450 size = sizeof(BOOL);
[1505]1451 PrfQueryProfileData(fmprof, FM3Str, "ExternalViewer", &fExternalViewer, &size);
[1333]1452 size = sizeof(BOOL);
[1505]1453 PrfQueryProfileData(fmprof, FM3Str, "UseQProcStat", &fUseQProcStat, &size);
[1333]1454 size = sizeof(BOOL);
[1505]1455 PrfQueryProfileData(fmprof, FM3Str, "UseQSysState", &fUseQSysState, &size);
[1333]1456 size = sizeof(BOOL);
[1482]1457 PrfQueryProfileData(fmprof, appname, "DataMin", &fDataMin, &size);
[1333]1458 size = sizeof(BOOL);
[1328]1459 PrfQueryProfileData(fmprof, appname, "DataToFore", &fDataToFore, &size);
[1333]1460 size = sizeof(BOOL);
1461 PrfQueryProfileData(fmprof, appname, "DataShowDrives", &fDataShowDrives, &size);
1462 size = sizeof(BOOL);
1463 PrfQueryProfileData(fmprof, appname, "DataInclRemote", &fDataInclRemote, &size);
1464 size = sizeof(BOOL);
[1505]1465 PrfQueryProfileData(fmprof, FM3Str, "SplitStatus", &fSplitStatus, &size);
[1333]1466 size = sizeof(BOOL);
1467 PrfQueryProfileData(fmprof, appname, "FolderAfterExtract", &fFolderAfterExtract, &size);
1468 size = sizeof(BOOL);
[1482]1469 PrfQueryProfileData(fmprof, appname, "DullDatabar", &fDullMin, &size);
[1333]1470 size = sizeof(BOOL);
[1328]1471 PrfQueryProfileData(fmprof, appname, "BlueLED", &fBlueLED, &size);
[1333]1472 size = sizeof(BOOL);
1473 PrfQueryProfileData(fmprof, appname, "ConfirmDelete", &fConfirmDelete, &size);
[1471]1474 size = sizeof(BOOL);
[1505]1475 PrfQueryProfileData(fmprof, FM3Str, "SaveState", &fSaveState, &size);
[1328]1476 size = sizeof(BOOL);
1477 PrfQueryProfileData(fmprof, appname, "SyncUpdates", &fSyncUpdates, &size);
[1333]1478 size = sizeof(BOOL);
[1328]1479 PrfQueryProfileData(fmprof, appname, "LoadSubject", &fLoadSubject, &size);
[1333]1480 size = sizeof(BOOL);
[1328]1481 PrfQueryProfileData(fmprof, appname, "UnHilite", &fUnHilite, &size);
[1333]1482 size = sizeof(BOOL);
[1505]1483 PrfQueryProfileData(fmprof, FM3Str, "TileBackwards", &fTileBackwards, &size);
[1333]1484 size = sizeof(BOOL);
[1328]1485 PrfQueryProfileData(fmprof, appname, "LoadLongname", &fLoadLongnames, &size);
[1333]1486 size = sizeof(BOOL);
[1328]1487 PrfQueryProfileData(fmprof, appname, "VerifyWrites", &fVerify, &size);
[201]1488 DosSetVerify(fVerify);
[1333]1489 size = sizeof(BOOL);
[1328]1490 PrfQueryProfileData(fmprof, appname, "DontMoveMouse", &fDontMoveMouse, &size);
[1333]1491 size = sizeof(BOOL);
[1328]1492 PrfQueryProfileData(fmprof, appname, "NoIconsFiles", &fNoIconsFiles, &size);
[1333]1493 size = sizeof(BOOL);
[1328]1494 PrfQueryProfileData(fmprof, appname, "NoIconsDirs", &fNoIconsDirs, &size);
[1333]1495 size = sizeof(BOOL);
[1328]1496 PrfQueryProfileData(fmprof, appname, "ForceUpper", &fForceUpper, &size);
[1333]1497 size = sizeof(BOOL);
[1328]1498 PrfQueryProfileData(fmprof, appname, "ForceLower", &fForceLower, &size);
[1333]1499 size = sizeof(BOOL);
[1482]1500 PrfQueryProfileData(fmprof, appname, "TextTools", &fTextTools, &size);
[1333]1501 size = sizeof(BOOL);
[1482]1502 PrfQueryProfileData(fmprof, appname, "ToolTitles", &fToolTitles, &size);
[1333]1503 size = sizeof(BOOL);
[1328]1504 PrfQueryProfileData(fmprof, appname, "DoubleClickOpens", &fDCOpens, &size);
[1333]1505 size = sizeof(BOOL);
[1328]1506 PrfQueryProfileData(fmprof, appname, "LinkSetsIcon", &fLinkSetsIcon, &size);
[1664]1507 size = sizeof(BOOL);
1508 PrfQueryProfileData(fmprof, appname, "WarnReadOnly", &fWarnReadOnly, &size);
[1328]1509 size = sizeof(INT);
1510 PrfQueryProfileData(fmprof, appname, "Sort", &sortFlags, &size);
[1333]1511 size = sizeof(INT);
[1328]1512 PrfQueryProfileData(fmprof, appname, "TreeSort", &TreesortFlags, &size);
[1333]1513 size = sizeof(INT);
1514 PrfQueryProfileData(fmprof, appname, "CollectorSort", &CollectorsortFlags, &size);
1515 PrfQueryProfileString(fmprof, appname, "Targetdir", NULL, targetdir, sizeof(targetdir));
[201]1516 if (!IsValidDir(targetdir))
1517 *targetdir = 0;
[1333]1518 PrfQueryProfileString(fmprof, appname, "ExtractPath", NULL, extractpath, sizeof(extractpath));
[1328]1519 size = sizeof(BOOL);
[1482]1520 PrfQueryProfileData(fmprof, appname, "FileNamePathCnr", &fFileNameCnrPath, &size);
[1333]1521 PrfQueryProfileString(fmprof, appname, "Printer", "PRN", printer, sizeof(printer));
1522 PrfQueryProfileString(fmprof, appname, "DirCompare", NULL, dircompare, MaxComLineStrg);
1523 PrfQueryProfileString(fmprof, appname, "Viewer", NULL, viewer, MaxComLineStrg);
1524 PrfQueryProfileString(fmprof, appname, "Editor", NULL, editor, MaxComLineStrg);
1525 PrfQueryProfileString(fmprof, appname, "BinView", NULL, binview, MaxComLineStrg);
1526 PrfQueryProfileString(fmprof, appname, "BinEd", NULL, bined, MaxComLineStrg);
1527 PrfQueryProfileString(fmprof, appname, "Compare", NULL, compare, MaxComLineStrg);
1528 PrfQueryProfileString(fmprof, appname, "Virus", NULL, virus, MaxComLineStrg);
[1328]1529 size = sizeof(BOOL);
1530 PrfQueryProfileData(fmprof, appname, "FtpRunWPSDefault", &fFtpRunWPSDefault, &size);
[1333]1531 PrfQueryProfileString(fmprof, appname, "FTPRun", NULL, ftprun, MaxComLineStrg);
[917]1532 if (!*ftprun)
[892]1533 fFtpRunWPSDefault = TRUE;
[1328]1534 size = sizeof(BOOL);
1535 PrfQueryProfileData(fmprof, appname, "HttpRunWPSDefault", &fHttpRunWPSDefault, &size);
[1333]1536 PrfQueryProfileString(fmprof, appname, "HTTPRun", NULL, httprun, MaxComLineStrg);
[917]1537 if (!*httprun)
[892]1538 fHttpRunWPSDefault = TRUE;
[1333]1539 PrfQueryProfileString(fmprof, appname, "MailRun", NULL, mailrun, MaxComLineStrg);
1540 PrfQueryProfileString(fmprof, appname, "FtpRunDir", NULL, ftprundir, sizeof(ftprundir));
1541 PrfQueryProfileString(fmprof, appname, "HttpRunDir", NULL, httprundir, sizeof(httprundir));
1542 PrfQueryProfileString(fmprof, appname, "MailRunDir", NULL, mailrundir, sizeof(mailrundir));
1543 PrfQueryProfileString(fmprof, appname, "LastToolbar", NULL, lasttoolbar, sizeof(lasttoolbar));
[1328]1544 size = sizeof(BOOL);
[1333]1545 PrfQueryProfileData(fmprof, appname, "LibPathStrictHttpRun", &fLibPathStrictHttpRun, &size);
1546 size = sizeof(BOOL);
1547 PrfQueryProfileData(fmprof, appname, "LibPathStrictFtpRun", &fLibPathStrictFtpRun, &size);
1548 size = sizeof(BOOL);
1549 PrfQueryProfileData(fmprof, appname, "LibPathStrictMailRun", &fLibPathStrictMailRun, &size);
1550 size = sizeof(BOOL);
1551 PrfQueryProfileData(fmprof, appname, "NoMailtoMailRun", &fNoMailtoMailRun, &size);
1552 size = sizeof(BOOL);
1553 PrfQueryProfileData(fmprof, appname, "FollowTree", &fFollowTree, &size);
1554 size = sizeof(BOOL);
1555 PrfQueryProfileData(fmprof, appname, "StartMaximized", &fStartMaximized, &size);
[551]1556 if (!fStartMaximized) {
[1333]1557 size = sizeof(BOOL);
1558 PrfQueryProfileData(fmprof, appname, "StartMinimized", &fStartMinimized, &size);
[2]1559 }
[1333]1560 size = sizeof(BOOL);
[1328]1561 PrfQueryProfileData(fmprof, appname, "DefaultCopy", &fCopyDefault, &size);
[1333]1562 size = sizeof(BOOL);
[1328]1563 PrfQueryProfileData(fmprof, appname, "IdleCopy", &fRealIdle, &size);
[1333]1564 size = sizeof(BOOL);
1565 PrfQueryProfileData(fmprof, appname, "ArcStuffVisible", &fArcStuffVisible, &size);
1566 size = sizeof(BOOL);
[1482]1567 PrfQueryProfileData(fmprof, appname, "NoTreeGap", &fNoTreeGap, &size);
[1333]1568 size = sizeof(BOOL);
[1505]1569 PrfQueryProfileData(fmprof, FM3Str, "VTreeOpensWPS", &fVTreeOpensWPS, &size);
[1333]1570 size = sizeof(BOOL);
[1328]1571 PrfQueryProfileData(fmprof, appname, "RemoteBug", &fRemoteBug, &size);
[1333]1572 size = sizeof(BOOL);
[1354]1573 PrfQueryProfileData(fmprof, appname, "RScanLocal", &fRScanLocal, &size);
1574 size = sizeof(BOOL);
1575 PrfQueryProfileData(fmprof, appname, "RScanRemote", &fRScanRemote, &size);
1576 size = sizeof(BOOL);
1577 PrfQueryProfileData(fmprof, appname, "RScanVirtual", &fRScanVirtual, &size);
1578 size = sizeof(BOOL);
1579 PrfQueryProfileData(fmprof, appname, "RScanSlow", &fRScanSlow, &size);
1580 size = sizeof(BOOL);
1581 PrfQueryProfileData(fmprof, appname, "RScanNoWrite", &fRScanNoWrite, &size);
1582 size = sizeof(BOOL);
[1365]1583 PrfQueryProfileData(fmprof, appname, "EjectRemovableScan", &fEjectRemovableScan, &size);
1584 size = sizeof(BOOL);
1585 PrfQueryProfileData(fmprof, appname, "EjectCDScan", &fEjectCDScan, &size);
1586 size = sizeof(BOOL);
1587 PrfQueryProfileData(fmprof, appname, "EjectFlpyScan", &fEjectFlpyScan, &size);
1588 size = sizeof(BOOL);
[1333]1589 PrfQueryProfileData(fmprof, appname, "Drag&DropDlg", &fDragndropDlg, &size);
1590 size = sizeof(BOOL);
[1505]1591 PrfQueryProfileData(fmprof, FM3Str, "UserComboBox", &fUserComboBox, &size);
[1333]1592 size = sizeof(BOOL);
[1505]1593 PrfQueryProfileData(fmprof, FM3Str, "MinDirOnOpen", &fMinOnOpen, &size);
[1333]1594 size = sizeof(BOOL);
1595 PrfQueryProfileData(fmprof, appname, "QuickArcFind", &fQuickArcFind, &size);
1596 size = sizeof(BOOL);
[1482]1597 PrfQueryProfileData(fmprof, appname, "NoRemovableScan", &fNoRemovableScan, &size);
[1328]1598 size = sizeof(ULONG);
[1505]1599 PrfQueryProfileData(fmprof, FM3Str, "NoBrokenNotify", &NoBrokenNotify, &size);
[1333]1600 size = sizeof(ULONG);
1601 PrfQueryProfileData(fmprof, appname, "ContainerType", &ulCnrType, &size);
1602 size = sizeof(ULONG);
[1328]1603 PrfQueryProfileData(fmprof, appname, "FilesToGet", &FilesToGet, &size);
[789]1604 if (FilesToGet < FILESTOGET_MIN)
1605 FilesToGet = FILESTOGET_MIN;
1606 else if (FilesToGet > FILESTOGET_MAX)
1607 FilesToGet = FILESTOGET_MAX;
[1328]1608 size = sizeof(BOOL);
[1482]1609 PrfQueryProfileData(fmprof, appname, "AutoView", &fAutoView, &size);
[1333]1610 size = sizeof(BOOL);
[1482]1611 PrfQueryProfileData(fmprof, appname, "FM2Deletes", &fFM2Deletes, &size);
[1333]1612 size = sizeof(BOOL);
[1482]1613 PrfQueryProfileData(fmprof, appname, "TrashCan", &fTrashCan, &size);
[1642]1614 size = sizeof(BOOL);
1615 PrfQueryProfileData(fmprof, appname, "ThreadNotes", &fThreadNotes, &size);
1616 if (fThreadNotes)
1617 ShowNote();
[2]1618
[1409]1619 LoadDetailsSwitches(PCSZ_DIRCNR, &dsDirCnrDefault, FALSE);
[784]1620
[1673]1621 // load pointers and icons we use
[189]1622 hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE);
1623 hptrBusy = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
1624 hptrNS = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZENS, FALSE);
1625 hptrEW = WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE);
1626 hptrFloppy = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FLOPPY_ICON);
1627 hptrDrive = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DRIVE_ICON);
1628 hptrRemovable = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOVABLE_ICON);
1629 hptrCDROM = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, CDROM_ICON);
1630 hptrFile = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_ICON);
1631 hptrDir = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DIR_FRAME);
1632 hptrArc = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ARC_FRAME);
1633 hptrArt = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ART_ICON);
1634 hptrSystem = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_SYSTEM_ICON);
1635 hptrHidden = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_HIDDEN_ICON);
[552]1636 hptrReadonly = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FILE_READONLY_ICON);
[189]1637 hptrLast = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, LASTITEM_ICON);
1638 hptrRemote = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, REMOTE_ICON);
[552]1639 hptrVirtual = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, VIRTUAL_ICON);
1640 hptrRamdisk = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, RAMDISK_ICON);
[189]1641 if (!fNoDead)
1642 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER_ICON);
[2]1643 else
[189]1644 hptrFinger = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, FINGER2_ICON);
1645 hptrApp = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, APP_ICON);
1646 hptrDunno = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, DUNNO_ICON);
1647 hptrEnv = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ENV_ICON);
1648 hptrZipstrm = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, ZIPSTREAM_ICON);
[2]1649
[201]1650 // set up color array used by seeall.c and newview.c color dialog
1651
[189]1652 standardcolors[0] = CLR_WHITE;
1653 standardcolors[1] = CLR_BLACK;
1654 standardcolors[2] = CLR_BLUE;
1655 standardcolors[3] = CLR_RED;
1656 standardcolors[4] = CLR_PINK;
1657 standardcolors[5] = CLR_GREEN;
1658 standardcolors[6] = CLR_CYAN;
1659 standardcolors[7] = CLR_YELLOW;
1660 standardcolors[8] = CLR_DARKGRAY;
1661 standardcolors[9] = CLR_DARKBLUE;
[2]1662 standardcolors[10] = CLR_DARKRED;
1663 standardcolors[11] = CLR_DARKPINK;
1664 standardcolors[12] = CLR_DARKGREEN;
1665 standardcolors[13] = CLR_DARKCYAN;
1666 standardcolors[14] = CLR_BROWN;
1667 standardcolors[15] = CLR_PALEGRAY;
1668
1669 return TRUE;
1670}
1671
[189]1672HWND StartFM3(HAB hab, INT argc, CHAR ** argv)
1673{
[201]1674 HWND hwndFrame;
1675 HWND hwndClient;
1676 UINT x;
[189]1677 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
[551]1678 FCF_SIZEBORDER | FCF_MINMAX |
1679 FCF_ACCELTABLE | FCF_MENU | FCF_ICON | FCF_TASKLIST | FCF_NOBYTEALIGN;
[2]1680
[551]1681 for (x = 1; x < argc; x++) {
[201]1682 if (*argv[x] == '~' && !argv[x][1])
1683 fReminimize = TRUE;
1684 if (*argv[x] == '+' && !argv[x][1])
1685 fLogFile = TRUE;
[551]1686 if (*argv[x] == '-') {
[201]1687 if (!argv[x][1])
[1335]1688 fNoSaveState = TRUE;
[201]1689 else
[1335]1690 strcpy(profile, &argv[x][1]);
[2]1691 }
[1720]1692 if (*argv[x] == '#' && !argv[x][1])
1693 fUseShellEnv = TRUE;
[2]1694 }
1695
1696 hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
[1335]1697 WS_VISIBLE,
1698 &FrameFlags,
[1498]1699 (CHAR *) WC_MAINWND,
[1335]1700 NULL,
1701 WS_VISIBLE | WS_ANIMATE,
1702 FM3ModHandle, MAIN_FRAME, &hwndClient);
[551]1703 if (hwndFrame) {
1704 WinSetWindowUShort(hwndFrame, QWS_ID, MAIN_FRAME);
[875]1705 hwndMainMenu = WinWindowFromID(hwndFrame, FID_MENU);
[1498]1706 if (!WinRestoreWindowPos((CHAR *) FM2Str, "MainWindowPos", hwndFrame)) {
[2]1707
1708 ULONG fl = SWP_MOVE | SWP_SIZE;
1709 RECTL rcl;
[189]1710 ULONG icz = WinQuerySysValue(HWND_DESKTOP, SV_CYICON) * 3L;
1711 ULONG bsz = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
[2]1712
[551]1713 WinQueryWindowRect(HWND_DESKTOP, &rcl);
[2]1714 rcl.yBottom += icz;
1715 rcl.yTop -= bsz;
1716 rcl.xLeft += bsz;
1717 rcl.xRight -= bsz;
1718 WinSetWindowPos(hwndFrame,
[1335]1719 HWND_TOP,
1720 rcl.xLeft,
1721 rcl.yBottom,
1722 rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, fl);
[2]1723 }
[1544]1724 if (fLogFile) {
1725 CHAR *modea = "a+";
1726
1727 LogFileHandle = xfsopen("FM2.LOG", modea, SH_DENYWR, pszSrcFile, __LINE__, TRUE);
1728 }
[189]1729 if (hwndHelp)
[551]1730 WinAssociateHelpInstance(hwndHelp, hwndFrame);
1731 PostMsg(hwndClient, UM_SETUP, MPFROMLONG(argc), MPFROMP(argv));
[2]1732 }
1733 return hwndFrame;
1734}
[32]1735
[985]1736BOOL CheckFileHeader(CHAR *filespec, CHAR *signature, LONG offset)
1737{
1738 HFILE handle;
1739 ULONG action;
1740 ULONG len = strlen(signature);
1741 ULONG l;
[1156]1742 CHAR buffer[4096]; // 06 Oct 07 SHL Protect against NTFS defect
[985]1743 BOOL ret = FALSE;
1744
1745 DosError(FERR_DISABLEHARDERR);
1746 if (DosOpen(filespec,
[1335]1747 &handle,
1748 &action,
1749 0,
1750 0,
1751 OPEN_ACTION_FAIL_IF_NEW |
1752 OPEN_ACTION_OPEN_IF_EXISTS,
1753 OPEN_FLAGS_FAIL_ON_ERROR |
1754 OPEN_FLAGS_NOINHERIT |
1755 OPEN_FLAGS_RANDOMSEQUENTIAL |
1756 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0))
[985]1757 ret = FALSE;
1758 else {
1759 // Try signature match
1760 l = len;
1761 l = min(l, 79);
1762 if (!DosChgFilePtr(handle,
[1335]1763 abs(offset),
1764 (offset >= 0) ?
1765 FILE_BEGIN : FILE_END, &len)) {
[985]1766 if (!DosRead(handle, buffer, l, &len) && len == l) {
[1335]1767 if (!memcmp(signature, buffer, l))
1768 ret = TRUE; // Matched
[985]1769 }
1770 }
1771 }
[1673]1772 DosClose(handle); // Either way, we're done for now
1773 return ret; // Return TRUE if matched
[985]1774}
1775
[189]1776int CheckVersion(int vermajor, int verminor)
1777{
[179]1778 int ok = 0;
[32]1779
[179]1780 // fixme to do useful check - was missing in base source
1781
[32]1782#if 0
[551]1783 if (vermajor && verminor) {
[32]1784 *vermajor = VERMAJOR;
1785 *verminor = VERMINOR;
[179]1786 ok = 1;
[32]1787 }
1788#endif
[189]1789
[179]1790 ok = 1;
[32]1791
[179]1792 return ok;
[32]1793}
[783]1794
1795#ifdef __WATCOMC__
1796#pragma alloc_text(INIT,LibMain,InitFM3DLL,DeInitFM3DLL)
1797#pragma alloc_text(INIT1,StartFM3,FindSwapperDat)
1798#endif
Note: See TracBrowser for help on using the repository browser.