source: trunk/dll/init.c@ 1713

Last change on this file since 1713 was 1713, checked in by Gregg Young, 12 years ago

Change to use old ini key name for separate settings in case someone has it set.

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