home *** CD-ROM | disk | FTP | other *** search
/ ftp.sberbank.sumy.ua / 2014.11.ftp.sberbank.sumy.ua.tar / ftp.sberbank.sumy.ua / incoming / 1 / TimeOutFile.asm < prev    next >
Assembly Source File  |  2014-02-08  |  7KB  |  283 lines

  1.       .386
  2.       .model flat, stdcall  ; 32 bit memory model
  3.       option casemap :none  ; case sensitive
  4.  
  5.  
  6.       include \masm32\include\windows.inc
  7.       include \masm32\include\user32.inc
  8.       include \masm32\include\kernel32.inc
  9.       include \masm32\include\gdi32.inc
  10.       
  11.       includelib \masm32\lib\user32.lib
  12.       includelib \masm32\lib\kernel32.lib
  13.       includelib \masm32\lib\gdi32.lib
  14.  
  15.       return MACRO arg
  16.         mov eax, arg
  17.         ret
  18.       ENDM
  19.  
  20.  
  21.   WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
  22.   WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
  23.   GetCurrentTimeLoc PROTO  
  24.   OutputDateToFileLoc PROTO :DWORD
  25.  
  26. .data
  27.  
  28.  cEVK          db "Evgeney Victorovich Kupin 27 April 1982",0 
  29.  
  30.  szClassName   db "Evgeney_Victorovich_Kupin_27_April_1982",0
  31.  szDisplayName db "<>",0
  32.  cFormatOut    db "%d %s %04d  %s  %d:%02d",0
  33.  cFormatFindFile db "T%07d%s",0
  34.  strTxt db ".txt",0         
  35.  cWriteFileName db 256 dup(0) 
  36.  cDateString   db 256 dup(0)
  37.  
  38.  cMonthString  db "January",0,"February",0,"March",0,"April",0,"May",0,"June",0,\
  39.                   "July",0,"August",0,"September",0,"October",0,"November",0,"December",0 
  40.  
  41.  cWeekString   db "Sunday",0,"Monday",0,"Tuesday",0,"Wednesday",0,"Thursday",0,\
  42.                   "Friday",0,"Saturday",0
  43.  
  44.  
  45.  CommandLine   dd 0
  46.  hWnd          dd 0
  47.  hInstance     dd 0
  48.  
  49.  hIcon                   dd  ? 
  50.  hinstLib                dd  ?  
  51.  JpegFileToBitmapFile    dd  ?
  52.  
  53.  Day    dd 0
  54.  Month  dd 0
  55.  Year   dd 0
  56.  Week   dd 0
  57.  Hour   dd 0
  58.  Minute dd 0
  59.  
  60.  number dd 0
  61.  hFindFile dd 0 
  62.  
  63.  sysTime  SYSTEMTIME <0>
  64.  strFindFile   WIN32_FIND_DATA <0>
  65.  
  66. .code
  67.  
  68. start:
  69.       invoke GetModuleHandle, NULL
  70.       mov hInstance, eax
  71.  
  72.       invoke GetCommandLine
  73.       mov CommandLine, eax
  74.  
  75.       invoke WinMain, hInstance,NULL,CommandLine,SW_SHOWDEFAULT
  76.       invoke ExitProcess,eax
  77.  
  78. WinMain proc hInst     :DWORD, hPrevInst :DWORD, CmdLine   :DWORD, CmdShow   :DWORD
  79.  
  80.       LOCAL wc   :WNDCLASSEX
  81.       LOCAL msg  :MSG
  82.  
  83.       mov wc.cbSize,          sizeof WNDCLASSEX
  84.       mov wc.style,           CS_HREDRAW or CS_VREDRAW \
  85.                               or CS_BYTEALIGNWINDOW
  86.       mov  wc.lpfnWndProc,    offset WndProc
  87.       mov  wc.cbClsExtra,     NULL
  88.       mov  wc.cbWndExtra,     NULL
  89.       push hInst
  90.       pop  wc.hInstance
  91.       mov  wc.hbrBackground,  COLOR_WINDOW
  92.       mov  wc.lpszMenuName,   NULL
  93.       mov  wc.lpszClassName,  offset szClassName
  94.       push hIcon
  95.       pop  wc.hIcon
  96.       invoke LoadCursor,NULL,IDC_ARROW
  97.       mov  wc.hCursor,        eax
  98.       push hIcon 
  99.       pop  wc.hIconSm
  100.  
  101.       invoke RegisterClassEx, ADDR wc
  102.  
  103.  
  104.       invoke CreateWindowEx,WS_EX_LEFT,
  105.                             ADDR szClassName,
  106.                             ADDR szDisplayName,
  107.                             WS_OVERLAPPEDWINDOW,
  108.                             0,0,500,500,
  109.                             NULL,NULL,
  110.                             hInst,NULL
  111.       mov   hWnd,eax
  112.  
  113.       invoke ShowWindow,hWnd,SW_SHOWNORMAL
  114.       invoke UpdateWindow,hWnd
  115.  
  116.     StartLoop:
  117.       invoke GetMessage,ADDR msg,NULL,0,0
  118.       cmp eax, 0
  119.       je ExitLoop
  120.       invoke TranslateMessage, ADDR msg
  121.       invoke DispatchMessage,  ADDR msg
  122.       jmp StartLoop
  123.     ExitLoop:
  124.  
  125.       return msg.wParam
  126.  
  127. WinMain endp
  128.  
  129. OutputDateToFileLoc proc cbLength:DWORD
  130.    LOCAL hTextFile :DWORD
  131.    LOCAL dwBytesWritten :DWORD
  132.  
  133.         mov number,0 
  134.  
  135. OutputDateToFileLoc_find_file:
  136.         invoke wsprintf, addr cWriteFileName, addr cFormatFindFile, number, addr strTxt
  137.  
  138.         invoke FindFirstFile, addr cWriteFileName, addr strFindFile 
  139.         mov    hFindFile, eax
  140.         cmp eax, INVALID_HANDLE_VALUE
  141.         je  OutputDateToFileLoc_exit         
  142.         inc number 
  143.         invoke  FindClose, hFindFile
  144.         jmp OutputDateToFileLoc_find_file
  145.  
  146. OutputDateToFileLoc_exit:
  147.  
  148.       invoke CreateFile, addr cWriteFileName, GENERIC_WRITE,\
  149.               0, NULL, CREATE_ALWAYS,\
  150.               FILE_ATTRIBUTE_NORMAL, NULL
  151.         mov hTextFile, eax
  152.       
  153.         invoke WriteFile, hTextFile, addr cDateString, cbLength,\
  154.                           addr dwBytesWritten, NULL
  155.  
  156.         invoke CloseHandle, hTextFile
  157.         ret
  158. OutputDateToFileLoc endp
  159.  
  160. GetCurrentTimeLoc proc
  161.  
  162.         invoke GetLocalTime, addr sysTime 
  163.  
  164.         mov eax,0
  165.         mov ax, sysTime.wDay 
  166.         mov Day, eax
  167.  
  168.         xor ecx, ecx
  169.         mov cx, sysTime.wYear
  170.         mov Year, ecx    
  171.  
  172.         and eax, 0 
  173.         mov ax, sysTime.wMonth
  174.         mov Month, eax
  175.  
  176.         and eax, 0 
  177.         mov ax, sysTime.wDayOfWeek
  178.         mov Week, eax
  179.  
  180.         and eax, 0 
  181.         mov ax, sysTime.wHour
  182.         mov Hour, eax
  183.  
  184.         and eax, 0 
  185.         mov ax, sysTime.wMinute
  186.         mov Minute, eax
  187.  
  188.  
  189.        push edi 
  190.         cld
  191.         lea edi, cMonthString
  192.         mov al,0
  193.         xor ecx,ecx
  194. GetCurrentTimeLoc_get_month:
  195.         repne scasb  
  196.         mov ecx, 120
  197.         dec Month
  198.         jnz GetCurrentTimeLoc_get_month         
  199.         mov Month, edi 
  200.        pop edi  
  201.  
  202.        push edi 
  203.         cld
  204.         lea edi, cWeekString
  205.         mov al,0
  206.         xor ecx,ecx
  207. GetCurrentTimeLoc_get_week:
  208.         repne scasb  
  209.         mov ecx, 120
  210.         dec Week
  211.         jns GetCurrentTimeLoc_get_week         
  212.         mov Week, edi 
  213.        pop edi  
  214.  
  215.         invoke wsprintf, addr cDateString, addr cFormatOut, Day, Month, Year, Week,\
  216.                          Hour, Minute            
  217.  
  218.         ret 
  219. GetCurrentTimeLoc endp
  220.  
  221. WndProc proc hWin   :DWORD, uMsg   :DWORD, wParam :DWORD, lParam :DWORD
  222.  
  223.     LOCAL Ps   :PAINTSTRUCT
  224.     LOCAL hDC  :DWORD
  225.  
  226.     .if uMsg == WM_CREATE
  227.         push edi
  228.         push esi
  229.  
  230.         cld 
  231.         mov ecx, 39
  232.         lea esi, cEVK
  233.         lea edi, cDateString
  234.         rep movsb          
  235.  
  236.         pop  esi
  237.         pop  edi 
  238.  
  239.         return 0
  240.  
  241.     .elseif uMsg == WM_TIMECHANGE
  242.  
  243.         invoke InvalidateRect, hWin,0,TRUE
  244.         return 0          
  245.  
  246.     .elseif uMsg == WM_PAINT
  247.         invoke BeginPaint,hWin,ADDR Ps
  248.         mov hDC, eax
  249.  
  250.         invoke GetCurrentTimeLoc 
  251.  
  252.         cld
  253.        push edi
  254.         lea edi, cDateString
  255.         and al, 0
  256.         mov ecx, 50  
  257.         repne scasb        
  258.         mov eax,49
  259.         sub eax, ecx 
  260.        pop edi     
  261.  
  262.        push eax
  263.         invoke OutputDateToFileLoc, eax
  264.  
  265.        pop  eax
  266.  
  267.         invoke TextOut, hDC, 10, 10, addr cDateString, eax
  268.  
  269.         invoke EndPaint,hWin,ADDR Ps
  270.         return 0
  271.  
  272.     .elseif uMsg == WM_DESTROY
  273.         invoke PostQuitMessage,NULL
  274.         return 0 
  275.     .endif
  276.  
  277.     invoke DefWindowProc,hWin,uMsg,wParam,lParam
  278.  
  279.     ret
  280.  
  281. WndProc endp
  282. end start
  283.