[907] | 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
|
---|
[1341] | 12 | 14 Dec 08 SHL Add exception handler support
|
---|
[907] | 13 |
|
---|
| 14 | ***********************************************************************/
|
---|
| 15 |
|
---|
| 16 | #include <string.h>
|
---|
| 17 |
|
---|
[2] | 18 | #define INCL_DOS
|
---|
| 19 | #define INCL_WIN
|
---|
[1341] | 20 | #define INCL_DOSEXCEPTIONS // XCTP_...
|
---|
| 21 | #define INCL_DOSERRORS // NO_ERROR
|
---|
[2] | 22 |
|
---|
| 23 | #include "dll\fm3dll.h"
|
---|
[1341] | 24 | #include "dll\mainwnd.h" // hwndHelp
|
---|
| 25 | #include "dll\notebook.h" // appname
|
---|
[1176] | 26 | #include "dll\init.h" // InitFM3DLL
|
---|
| 27 | #include "dll\valid.h" // IsFile
|
---|
| 28 | #include "dll\dirs.h" // save_dir
|
---|
[1341] | 29 | #include "dll\errutil.h" // Error reporting
|
---|
| 30 | #include "dll\excputil.h" // Exception handlers
|
---|
[2] | 31 |
|
---|
[1341] | 32 | static PSZ pszSrcFile = __FILE__;
|
---|
| 33 |
|
---|
[551] | 34 | int main(int argc, char *argv[])
|
---|
| 35 | {
|
---|
| 36 | HAB hab;
|
---|
| 37 | HMQ hmq;
|
---|
| 38 | QMSG qmsg;
|
---|
| 39 | HWND hwndFrame;
|
---|
[1341] | 40 | CHAR fullname[CCHMAXPATH];
|
---|
| 41 | PSZ thisarg = NULL;
|
---|
| 42 | UINT x;
|
---|
| 43 | APIRET regRet;
|
---|
| 44 | EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
|
---|
[2] | 45 |
|
---|
[551] | 46 | strcpy(appname, "VDIR");
|
---|
[2] | 47 | DosError(FERR_DISABLEHARDERR);
|
---|
[1341] | 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 |
|
---|
[551] | 56 | for (x = 1; x < argc; x++) {
|
---|
| 57 | if (!strchr("/;,`\'", *argv[x]) && (IsRoot(argv[x]) || !IsFile(argv[x]))) {
|
---|
[2] | 58 | thisarg = argv[x];
|
---|
| 59 | break;
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
| 62 |
|
---|
[551] | 63 | if (thisarg) {
|
---|
| 64 | if (DosQueryPathInfo(thisarg,
|
---|
| 65 | FIL_QUERYFULLNAME, fullname, sizeof(fullname)))
|
---|
| 66 | strcpy(fullname, thisarg);
|
---|
[2] | 67 | }
|
---|
| 68 | else
|
---|
| 69 | save_dir(fullname);
|
---|
[1341] | 70 |
|
---|
[2] | 71 | hab = WinInitialize(0);
|
---|
[551] | 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 | }
|
---|
[2] | 97 | }
|
---|
| 98 | DosSleep(125L);
|
---|
| 99 | WinDestroyMsgQueue(hmq);
|
---|
| 100 | }
|
---|
| 101 | WinTerminate(hab);
|
---|
| 102 | }
|
---|
| 103 | return 0;
|
---|
| 104 | }
|
---|