home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 20.ddi / SAMPLES / DDEML / CLOCK / GETTIME.C_ / GETTIME.C
Encoding:
C/C++ Source or Header  |  1993-02-08  |  1.1 KB  |  46 lines

  1. /* 
  2.  * GETTIME.C
  3.  * Gets time efficiently from the system.
  4.  */
  5.  
  6. #include <windows.h>
  7. #include <ddeml.h> 
  8. #include <string.h>
  9. #include "wrapper.h" 
  10. #include "ddemlclk.h"
  11.  
  12. #pragma warning(disable:4704)
  13.  
  14. void GetTime(TIME * pTime) {
  15.     __asm { 
  16.         mov     ax, 2c00h                  ; get time
  17.         int     21h
  18.         mov     bx, pTime
  19.         cmp     ch, 12                  ; if hour <12
  20.         jl      lt12                    ; we're ok
  21.         sub     ch,12                   ; else adjust it
  22. lt12:
  23.         xor     ax,ax
  24.         mov     al,ch
  25.         mov     [bx].hour, ax
  26.         mov     al,cl
  27.         mov     [bx].minute, ax
  28.         mov     al,dh
  29.         mov     [bx].second, ax 
  30.         }
  31.     }  
  32.     
  33. void SetTime(TIME * pTime ) {
  34.     __asm {
  35.         mov     bx, pTime
  36.         mov     ax, [bx].hour
  37.         mov     ch, al
  38.         mov     ax, [bx].minute
  39.         mov     cl, al
  40.         mov     ax, [bx].second
  41.         mov     dh, al
  42.         mov     ax, 2d00h           ; set time
  43.         mov     dl, al
  44.         int     21h          
  45.         }
  46.     }