home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / MKMSG104 / MKDOS.PAS < prev    next >
Pascal/Delphi Source File  |  1994-01-09  |  2KB  |  121 lines

  1. Unit MKDos;
  2. {$I MKB.Def}
  3.  
  4. Interface
  5.  
  6.  
  7. Function GetDosDate: LongInt;
  8. Function GetDOW: Word;
  9. Function GetResultCode: Integer;
  10. Function TimeOut(Time:LongInt):Boolean; {If time is later than current time
  11.   in timerticks}
  12.  
  13. Var
  14.   TimeCounter: LongInt Absolute $40:$6C;
  15.  
  16.  
  17.  
  18. Implementation
  19.  
  20.  
  21. Uses
  22.   {$IFDEF WINDOWS}
  23.   WinDos;
  24.   {$ELSE}
  25.   Dos;
  26.   {$ENDIF}
  27.  
  28.  
  29. Function TimeOut(Time:LongInt):Boolean;
  30.   Var
  31.     TimeDiff: LongInt;
  32.  
  33.   Begin
  34.   TimeDiff := Time - TimeCounter;
  35.   If TimeDiff < 0 Then
  36.     TimeOut := True
  37.   Else
  38.     Begin
  39.     If (TimeDiff > 780000) Then
  40.     Dec(TimeDiff, 1572480);
  41.     If TimeDiff < 0 Then
  42.       TimeOut := True
  43.     Else
  44.       TimeOut := False;
  45.     End;
  46.   End;
  47.  
  48.  
  49.  
  50. Function GetResultCode: Integer;
  51.   Var
  52.     Result: Byte;
  53.   {$IFNDEF BASMINT}
  54.     {$IFDEF WINDOWS}
  55.     Regs: TRegisters;
  56.     {$ELSE}
  57.     Regs: Registers;
  58.     {$ENDIF}
  59.   {$ENDIF}
  60.  
  61.   Begin
  62.   {$IFDEF BASMINT}
  63.   Asm
  64.     Mov ah, $4d;
  65.     Int $21;
  66.     Cmp ah, $00;
  67.     je @JRes;
  68.     Neg ah;
  69.     Mov Result, ah;
  70.     jmp @JRes2;
  71.     @JRes:
  72.     Mov Result, al;
  73.     @JRes2:
  74.     End;
  75.   {$ELSE}
  76.   Regs.ah := $4d;
  77.   MsDos(Regs);
  78.   If Regs.ah <> 0 Then
  79.     Result := - Regs.ah
  80.   Else
  81.     Result := Regs.al;
  82.   {$ENDIF}
  83.   GetResultCode := Result;
  84.   End;
  85.  
  86.  
  87. Function GetDosDate: LongInt;
  88.   Var
  89.     {$IFDEF WINDOWS}
  90.     DT: TDateTime;
  91.     {$ELSE}
  92.     DT: DateTime;
  93.     {$ENDIF}
  94.     DosDate: LongInt;
  95.     DOW: Word;
  96.  
  97.   Begin
  98.   GetDate(DT.Year, DT.Month, DT.Day, DOW);
  99.   GetTime(DT.Hour, DT.Min, DT.Sec, DOW);
  100.   PackTime(DT, DosDate);
  101.   GetDosDate := DosDate;
  102.   End;
  103.  
  104.  
  105. Function GetDOW: Word;
  106.   Var
  107.     {$IFDEF WINDOWS}
  108.     DT: TDateTime;
  109.     {$ELSE}
  110.     DT: DateTime;
  111.     {$ENDIF}
  112.     DOW: Word;
  113.  
  114.   Begin
  115.   GetDate(DT.Year, DT.Month, DT.Day, DOW);
  116.   GetDOW := DOW;
  117.   End;
  118.  
  119.  
  120. End.
  121.