1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: vdir.c 1341 2008-12-14 22:18:26Z stevenhl $
|
---|
5 |
|
---|
6 | INF directory viewer applet
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2007, 2008 Steven H.Levine
|
---|
10 |
|
---|
11 | 05 Jan 08 SHL Sync
|
---|
12 | 14 Dec 08 SHL Add exception handler support
|
---|
13 |
|
---|
14 | ***********************************************************************/
|
---|
15 |
|
---|
16 | #include <string.h>
|
---|
17 |
|
---|
18 | #define INCL_DOS
|
---|
19 | #define INCL_WIN
|
---|
20 | #define INCL_DOSEXCEPTIONS // XCTP_...
|
---|
21 | #define INCL_DOSERRORS // NO_ERROR
|
---|
22 |
|
---|
23 | #include "dll\fm3dll.h"
|
---|
24 | #include "dll\mainwnd.h" // hwndHelp
|
---|
25 | #include "dll\notebook.h" // appname
|
---|
26 | #include "dll\init.h" // InitFM3DLL
|
---|
27 | #include "dll\valid.h" // IsFile
|
---|
28 | #include "dll\dirs.h" // save_dir
|
---|
29 | #include "dll\errutil.h" // Error reporting
|
---|
30 | #include "dll\excputil.h" // Exception handlers
|
---|
31 |
|
---|
32 | static PSZ pszSrcFile = __FILE__;
|
---|
33 |
|
---|
34 | int main(int argc, char *argv[])
|
---|
35 | {
|
---|
36 | HAB hab;
|
---|
37 | HMQ hmq;
|
---|
38 | QMSG qmsg;
|
---|
39 | HWND hwndFrame;
|
---|
40 | CHAR fullname[CCHMAXPATH];
|
---|
41 | PSZ thisarg = NULL;
|
---|
42 | UINT x;
|
---|
43 | APIRET regRet;
|
---|
44 | EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
|
---|
45 |
|
---|
46 | strcpy(appname, "VDIR");
|
---|
47 | DosError(FERR_DISABLEHARDERR);
|
---|
48 |
|
---|
49 | regRec.ExceptionHandler = HandleException;
|
---|
50 | regRet = DosSetExceptionHandler(®Rec);
|
---|
51 | if (regRet != NO_ERROR) {
|
---|
52 | DbgMsg(pszSrcFile, __LINE__,
|
---|
53 | "DosSetExceptionHandler failed with error %u", regRet);
|
---|
54 | }
|
---|
55 |
|
---|
56 | for (x = 1; x < argc; x++) {
|
---|
57 | if (!strchr("/;,`\'", *argv[x]) && (IsRoot(argv[x]) || !IsFile(argv[x]))) {
|
---|
58 | thisarg = argv[x];
|
---|
59 | break;
|
---|
60 | }
|
---|
61 | }
|
---|
62 |
|
---|
63 | if (thisarg) {
|
---|
64 | if (DosQueryPathInfo(thisarg,
|
---|
65 | FIL_QUERYFULLNAME, fullname, sizeof(fullname)))
|
---|
66 | strcpy(fullname, thisarg);
|
---|
67 | }
|
---|
68 | else
|
---|
69 | save_dir(fullname);
|
---|
70 |
|
---|
71 | hab = WinInitialize(0);
|
---|
72 | if (hab) {
|
---|
73 | hmq = WinCreateMsgQueue(hab, 1024);
|
---|
74 | if (hmq) {
|
---|
75 | if (InitFM3DLL(hab, argc, argv)) {
|
---|
76 | hwndFrame = StartDirCnr(HWND_DESKTOP, fullname, (HWND) 0, 0);
|
---|
77 | if (hwndFrame) {
|
---|
78 | if (hwndHelp)
|
---|
79 | WinAssociateHelpInstance(hwndHelp, hwndFrame);
|
---|
80 | for (;;) {
|
---|
81 | if (!WinGetMsg(hab, &qmsg, (HWND) 0, 0, 0)) {
|
---|
82 | if (qmsg.hwnd)
|
---|
83 | qmsg.msg = WM_CLOSE;
|
---|
84 | else
|
---|
85 | break;
|
---|
86 | }
|
---|
87 | if (hwndBubble &&
|
---|
88 | ((qmsg.msg > (WM_BUTTON1DOWN - 1) &&
|
---|
89 | qmsg.msg < (WM_BUTTON3DBLCLK + 1)) ||
|
---|
90 | (qmsg.msg > (WM_CHORD - 1) &&
|
---|
91 | qmsg.msg < (WM_BUTTON3CLICK + 1))) &&
|
---|
92 | WinIsWindowVisible(hwndBubble))
|
---|
93 | WinShowWindow(hwndBubble, FALSE);
|
---|
94 | WinDispatchMsg(hab, &qmsg);
|
---|
95 | }
|
---|
96 | }
|
---|
97 | }
|
---|
98 | DosSleep(125L);
|
---|
99 | WinDestroyMsgQueue(hmq);
|
---|
100 | }
|
---|
101 | WinTerminate(hab);
|
---|
102 | }
|
---|
103 | return 0;
|
---|
104 | }
|
---|