home *** CD-ROM | disk | FTP | other *** search
/ Current Shareware 1994 January / SHAR194.ISO / dos_util / v12n19.zip / FILCDR.ZIP / CRTLOG.PAS < prev    next >
Pascal/Delphi Source File  |  1993-07-02  |  3KB  |  79 lines

  1. {$K+}
  2. PROGRAM CrtLog;
  3. USES WinCrt, WinTypes, WinProcs, Strings, Win31, FileCdrImport;
  4. CONST
  5.   AppName : PChar = 'CrtLog';
  6.   MsgName : PChar = 'CrtLog Message';
  7.   wm_FileSysChange = $0034;
  8. VAR
  9.   CrtHandle : hWnd;
  10.   OldProc   : TFarProc;
  11.  
  12.   PROCEDURE CheckINI;
  13.   VAR Value : ARRAY[0..20] OF Char;
  14.   BEGIN
  15.     GetPrivateProfileString('386Enh', 'FileSysChange', '', Value, 20,
  16.       'SYSTEM.INI');
  17.     IF StrIComp(Value, 'ON') <> 0 THEN
  18.       BEGIN
  19.         MessageBeep(mb_IconQuestion);
  20.         IF MessageBox(CrtHandle, 'Windows is not set up to receive '+
  21.           'notification of file activity in DOS boxes.  Enable this '+
  22.           'feature and restart Windows?', MsgName,
  23.           mb_YesNo + mb_IconQuestion) = id_Yes THEN
  24.           BEGIN
  25.              WritePrivateProfileString('386Enh', 'FileSysChange',
  26.                'ON', 'SYSTEM.INI');
  27.              ExitWindows(ew_RestartWindows, 0);
  28.           END;
  29.       END;
  30.   END;
  31.  
  32.   FUNCTION NewWinProc(Window : hWnd; Message, wParam : Word;
  33.     lParam : LongInt) : LongInt; EXPORT;
  34.   VAR buff : ARRAY[0..255] OF Char;
  35.   BEGIN
  36.     NewWinProc := CallWindowProc(OldProc, Window, Message, wParam,
  37.       lParam);
  38.     CASE Message OF
  39.       wm_Close : FileCdrUninstall(CrtHandle);
  40.       wm_FileSysChange : BEGIN
  41.         IF wParam > 9 THEN Write('(W) ') ELSE Write('(D) ');
  42.         Write(GetEventName(buff, wParam, 255), '':20-StrLen(buff));
  43.         StrCopy(buff, PChar(lParam));
  44.         IF (wParam = 2) OR (wParam = $56) THEN
  45.           BEGIN
  46.             StrCat(buff, ' TO ');
  47.             StrCat(buff, StrEnd(PChar(lParam))+1);
  48.           END;
  49.         WriteLn(StrUpper(buff));
  50.       END;
  51.     END;
  52.   END;
  53.  
  54. BEGIN
  55.   IF GetWinFlags AND WF_ENHANCED = 0 THEN
  56.     MessageBox(0, 'Because Windows is not in 386 Enhanced mode, '+
  57.       'CrtLog will not be able to log file events occurring in DOS '+
  58.       'boxes', MsgName, mb_Ok + mb_IconInformation)
  59.   ELSE CheckINI;
  60.   ScreenSize.X := (GetSystemMetrics(sm_CXScreen) -
  61.     GetSystemMetrics(sm_CXVScroll) -
  62.     GetSystemMetrics(sm_CXFrame)) DIV 8;
  63.   ScreenSize.Y := 65520 DIV ScreenSize.X;
  64.   AutoTracking := FALSE;
  65.   StrCopy(WindowTitle,   'CrtLog Window');
  66.   StrCopy(InactiveTitle, 'CrtLog Window');
  67.   InitWinCrt;
  68.   CrtHandle := GetActiveWindow;
  69.   IF NOT FileCdrInstall(CrtHandle) THEN
  70.     BEGIN
  71.       MessageBox(CrtHandle, 'The FileCdr function is already in use '+
  72.         'by another program - probably File Manager.', MsgName,
  73.         mb_Ok + mb_IconStop);
  74.       DoneWinCrt;
  75.     END;
  76.   OldProc := TFarProc(GetWindowLong(CrtHandle, gwl_WndProc));
  77.   SetWindowLong(CrtHandle, gwl_WndProc, LongInt(@NewWinProc));
  78. END.
  79.