|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
[FASM]-DATE ET HEURE
Information sur la source
Description
Tiré du code de x5man, j'en ai fait une version utilisable avec Flat Assembler et les API Windows ;)
Source
- format PE GUI 4.0
- entry start
-
- include 'win32a.inc'
-
- ; *****************************************************************************
- ; ***** Const
- ; *****************************************************************************
- ID_DIALOG = 10
- ID_GROUP_BOX = 100
-
- ID_LABEL_DATE = 101
- ID_LABEL_TIME = 102
- ID_LOCAL_TIME = 103
-
- ID_EDIT_DATE = 104
- ID_EDIT_TIME = 105
- ID_EDIT_LOCAL = 106
-
- ID_BUTTON_TIME = 107
- ID_BUTTON_QUIT = 108
-
- ; *****************************************************************************
- ; ***** Datas
- ; *****************************************************************************
- section '.data' data readable writeable
-
- hinstance dd ?
- IsError dd ?
- lpSystemTime SYSTEMTIME ; API struct
-
- _format_date db '%02u/%02u/%4u',0
- _buffer_date rb 11 ; 11 bytes reserved (xx/xx/xxxx0)
-
- _format_time db '%02d:%02d:%02d',0
- _buffer_time rb 9 ; 9 bytes reserved (xx:xx:xx0)
- _buffer_loc_time rb 9
-
- ; *****************************************************************************
- ; ***** Code
- ; *****************************************************************************
- section '.code' code readable executable
-
- start:
- invoke GetModuleHandle,0
- mov [hinstance],eax
- invoke DialogBoxParam,[hinstance],ID_DIALOG,HWND_DESKTOP,DialogProc,0
- invoke ExitProcess,0
-
- ; ***** Procedures
-
- proc DialogProc hwnddlg,msg,wparam,lparam
- push ebx esi edi
- cmp [msg],WM_INITDIALOG
- je wminitdialog ; called before dialog box is displayed
- cmp [msg],WM_COMMAND
- je wmcommand
- cmp [msg],WM_CLOSE
- je wmclose
- xor eax,eax ; eax = 0
- jmp finish
-
- wminitdialog:
- stdcall sys_time,[hwnddlg]
- stdcall loc_time,[hwnddlg]
- stdcall sys_date,[hwnddlg]
-
- jmp processed
-
- wmcommand:
- cmp [wparam],ID_BUTTON_QUIT ; BN_CLICKED shl 16 + ID_BUTTON_QUIT
- je wmclose ; goto close if click on Cancel
- ; invoke SendMessage,\
- ; ID_BUTTON_QUIT, BM_SETSTATE, TRUE, NULL
- invoke GetDlgItem,[hwnddlg],ID_BUTTON_QUIT ; ALWAYS put focus on button 'Quit'
- invoke SetFocus,eax
-
-
- cmp [wparam],ID_BUTTON_TIME ; BN_CLICKED shl 16 + ID_BUTTON_TIME
- jne processed ; <> Ok
- stdcall sys_time,[hwnddlg] ; Called when clicked on button 'Time'
- stdcall loc_time,[hwnddlg]
- jmp processed
-
- wmclose:
- invoke EndDialog,[hwnddlg],0
-
- processed:
- mov eax,1
-
- finish:
- pop edi esi ebx
- ret
- endp
-
- proc sys_time _hwnddlg
- invoke GetSystemTime,lpSystemTime
- movsx eax,[lpSystemTime.wHour] ; movsx (ou movzx) permet de
- movsx ebx,[lpSystemTime.wMinute] ; convertir en DWORD signed (ou unsigned)
- movsx edi,[lpSystemTime.wSecond] ; car wsprintf ne demande que du DWORD
- cinvoke wsprintf,_buffer_time,_format_time,eax,ebx,edi
- invoke SetDlgItemText,[_hwnddlg],ID_EDIT_TIME,_buffer_time
-
- ret ;return
- endp
-
- proc loc_time _hwnddlg
- invoke GetLocalTime,lpSystemTime
- movsx eax,[lpSystemTime.wHour]
- movsx ebx,[lpSystemTime.wMinute]
- movsx edi,[lpSystemTime.wSecond]
- cinvoke wsprintf,_buffer_loc_time,_format_time,eax,ebx,edi
- invoke SetDlgItemText,[_hwnddlg],ID_EDIT_LOCAL,_buffer_loc_time
-
- ret
- endp
-
- proc sys_date _hwnddlg
- movzx eax,[lpSystemTime.wDay] ; movzx (unsigned)
- movzx ebx,[lpSystemTime.wMonth]
- movzx edi,[lpSystemTime.wYear]
- invoke wsprintf,_buffer_date,_format_date,eax,ebx,edi ; using invoke because of unsigned word '%02u/%02u/%4u'
- invoke SetDlgItemText,[_hwnddlg],ID_EDIT_DATE,_buffer_date
-
- ret
- endp
-
- ; *****************************************************************************
- ; ***** Data Import
- ; *****************************************************************************
- section '.idata' import data readable writeable
-
- library kernel,'KERNEL32.DLL',\
- user,'USER32.DLL'
-
- import kernel,\
- GetModuleHandle,'GetModuleHandleA',\
- GetSystemTime, 'GetSystemTime',\
- GetLocalTime, 'GetLocalTime',\
- ExitProcess,'ExitProcess'
-
- import user,\
- DialogBoxParam,'DialogBoxParamA',\
- UpdateWindow,'UpdateWindow',\
- SendMessage,'SendMessageA',\
- SetDlgItemText,'SetDlgItemTextA',\ ; on peut aussi mettre SetDlgItemInt
- GetDlgItem,'GetDlgItem',\
- SetFocus,'SetFocus',\
- MessageBox,'MessageBoxA',\
- wsprintf,'wsprintfA',\
- LoadIcon,'LoadIconA',\
- EndDialog,'EndDialog'
-
- ; *****************************************************************************
- ; ***** Resources
- ; *****************************************************************************
- section '.rsrc' resource data readable
-
- directory RT_DIALOG,dialogs,\
- RT_ICON,rt_icons,\
- RT_GROUP_ICON,rt_group_icons
-
- resource dialogs,\
- ID_DIALOG,LANG_NEUTRAL+SUBLANG_DEFAULT,datesysteme
-
- resource rt_icons,\
- 200,LANG_NEUTRAL,icon_data
- resource rt_group_icons,\
- 201,LANG_NEUTRAL,main_icon
-
- dialog datesysteme,"System Date & Time by Flaith", 70, 70, 150, 110, DS_CENTER+DS_MODALFRAME+WS_POPUP+WS_VISIBLE+WS_CAPTION+WS_SYSMENU
- dialogitem 'STATIC','System date :', ID_LABEL_DATE , 10, 10, 45, 14, SS_RIGHT + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000000
- dialogitem 'STATIC','System Time :', ID_LABEL_TIME , 10, 30, 45, 14, SS_RIGHT + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000000
- dialogitem 'STATIC','Local Time :' , ID_LOCAL_TIME , 10, 50, 45, 14, SS_RIGHT + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000000
- dialogitem 'BUTTON','' , ID_GROUP_BOX , 60, 0, 85, 70, BS_GROUPBOX + WS_CHILD + WS_VISIBLE, 0x00000000
- dialogitem 'STATIC','__/__/____' , ID_EDIT_DATE , 70, 10, 65, 14, SS_CENTER + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000204
- dialogitem 'STATIC','__:__:__' , ID_EDIT_TIME , 70, 30, 65, 14, SS_CENTER + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000204
- dialogitem 'STATIC','__:__:__' , ID_EDIT_LOCAL , 70, 50, 65, 14, SS_CENTER + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000204
-
- ; button quit defined first (before time) with BS_DEFPUSHBUTTON value to give focus
-
- dialogitem 'BUTTON','&Quit' , ID_BUTTON_QUIT, 80, 80, 60, 28, WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON ;BS_DEFPUSHBUTTON + BS_VCENTER + BS_CENTER + WS_CHILD + WS_VISIBLE + WS_TABSTOP
- dialogitem 'BUTTON','&Time' , ID_BUTTON_TIME, 10, 80, 60, 28, WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON ;BS_PUSHBUTTON + BS_VCENTER + BS_CENTER + WS_CHILD + WS_VISIBLE + WS_TABSTOP
- enddialog
-
- icon main_icon,icon_data,'nico.ico' ; mettez l'icone que vous voulez
format PE GUI 4.0
entry start
include 'win32a.inc'
; *****************************************************************************
; ***** Const
; *****************************************************************************
ID_DIALOG = 10
ID_GROUP_BOX = 100
ID_LABEL_DATE = 101
ID_LABEL_TIME = 102
ID_LOCAL_TIME = 103
ID_EDIT_DATE = 104
ID_EDIT_TIME = 105
ID_EDIT_LOCAL = 106
ID_BUTTON_TIME = 107
ID_BUTTON_QUIT = 108
; *****************************************************************************
; ***** Datas
; *****************************************************************************
section '.data' data readable writeable
hinstance dd ?
IsError dd ?
lpSystemTime SYSTEMTIME ; API struct
_format_date db '%02u/%02u/%4u',0
_buffer_date rb 11 ; 11 bytes reserved (xx/xx/xxxx0)
_format_time db '%02d:%02d:%02d',0
_buffer_time rb 9 ; 9 bytes reserved (xx:xx:xx0)
_buffer_loc_time rb 9
; *****************************************************************************
; ***** Code
; *****************************************************************************
section '.code' code readable executable
start:
invoke GetModuleHandle,0
mov [hinstance],eax
invoke DialogBoxParam,[hinstance],ID_DIALOG,HWND_DESKTOP,DialogProc,0
invoke ExitProcess,0
; ***** Procedures
proc DialogProc hwnddlg,msg,wparam,lparam
push ebx esi edi
cmp [msg],WM_INITDIALOG
je wminitdialog ; called before dialog box is displayed
cmp [msg],WM_COMMAND
je wmcommand
cmp [msg],WM_CLOSE
je wmclose
xor eax,eax ; eax = 0
jmp finish
wminitdialog:
stdcall sys_time,[hwnddlg]
stdcall loc_time,[hwnddlg]
stdcall sys_date,[hwnddlg]
jmp processed
wmcommand:
cmp [wparam],ID_BUTTON_QUIT ; BN_CLICKED shl 16 + ID_BUTTON_QUIT
je wmclose ; goto close if click on Cancel
; invoke SendMessage,\
; ID_BUTTON_QUIT, BM_SETSTATE, TRUE, NULL
invoke GetDlgItem,[hwnddlg],ID_BUTTON_QUIT ; ALWAYS put focus on button 'Quit'
invoke SetFocus,eax
cmp [wparam],ID_BUTTON_TIME ; BN_CLICKED shl 16 + ID_BUTTON_TIME
jne processed ; <> Ok
stdcall sys_time,[hwnddlg] ; Called when clicked on button 'Time'
stdcall loc_time,[hwnddlg]
jmp processed
wmclose:
invoke EndDialog,[hwnddlg],0
processed:
mov eax,1
finish:
pop edi esi ebx
ret
endp
proc sys_time _hwnddlg
invoke GetSystemTime,lpSystemTime
movsx eax,[lpSystemTime.wHour] ; movsx (ou movzx) permet de
movsx ebx,[lpSystemTime.wMinute] ; convertir en DWORD signed (ou unsigned)
movsx edi,[lpSystemTime.wSecond] ; car wsprintf ne demande que du DWORD
cinvoke wsprintf,_buffer_time,_format_time,eax,ebx,edi
invoke SetDlgItemText,[_hwnddlg],ID_EDIT_TIME,_buffer_time
ret ;return
endp
proc loc_time _hwnddlg
invoke GetLocalTime,lpSystemTime
movsx eax,[lpSystemTime.wHour]
movsx ebx,[lpSystemTime.wMinute]
movsx edi,[lpSystemTime.wSecond]
cinvoke wsprintf,_buffer_loc_time,_format_time,eax,ebx,edi
invoke SetDlgItemText,[_hwnddlg],ID_EDIT_LOCAL,_buffer_loc_time
ret
endp
proc sys_date _hwnddlg
movzx eax,[lpSystemTime.wDay] ; movzx (unsigned)
movzx ebx,[lpSystemTime.wMonth]
movzx edi,[lpSystemTime.wYear]
invoke wsprintf,_buffer_date,_format_date,eax,ebx,edi ; using invoke because of unsigned word '%02u/%02u/%4u'
invoke SetDlgItemText,[_hwnddlg],ID_EDIT_DATE,_buffer_date
ret
endp
; *****************************************************************************
; ***** Data Import
; *****************************************************************************
section '.idata' import data readable writeable
library kernel,'KERNEL32.DLL',\
user,'USER32.DLL'
import kernel,\
GetModuleHandle,'GetModuleHandleA',\
GetSystemTime, 'GetSystemTime',\
GetLocalTime, 'GetLocalTime',\
ExitProcess,'ExitProcess'
import user,\
DialogBoxParam,'DialogBoxParamA',\
UpdateWindow,'UpdateWindow',\
SendMessage,'SendMessageA',\
SetDlgItemText,'SetDlgItemTextA',\ ; on peut aussi mettre SetDlgItemInt
GetDlgItem,'GetDlgItem',\
SetFocus,'SetFocus',\
MessageBox,'MessageBoxA',\
wsprintf,'wsprintfA',\
LoadIcon,'LoadIconA',\
EndDialog,'EndDialog'
; *****************************************************************************
; ***** Resources
; *****************************************************************************
section '.rsrc' resource data readable
directory RT_DIALOG,dialogs,\
RT_ICON,rt_icons,\
RT_GROUP_ICON,rt_group_icons
resource dialogs,\
ID_DIALOG,LANG_NEUTRAL+SUBLANG_DEFAULT,datesysteme
resource rt_icons,\
200,LANG_NEUTRAL,icon_data
resource rt_group_icons,\
201,LANG_NEUTRAL,main_icon
dialog datesysteme,"System Date & Time by Flaith", 70, 70, 150, 110, DS_CENTER+DS_MODALFRAME+WS_POPUP+WS_VISIBLE+WS_CAPTION+WS_SYSMENU
dialogitem 'STATIC','System date :', ID_LABEL_DATE , 10, 10, 45, 14, SS_RIGHT + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000000
dialogitem 'STATIC','System Time :', ID_LABEL_TIME , 10, 30, 45, 14, SS_RIGHT + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000000
dialogitem 'STATIC','Local Time :' , ID_LOCAL_TIME , 10, 50, 45, 14, SS_RIGHT + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000000
dialogitem 'BUTTON','' , ID_GROUP_BOX , 60, 0, 85, 70, BS_GROUPBOX + WS_CHILD + WS_VISIBLE, 0x00000000
dialogitem 'STATIC','__/__/____' , ID_EDIT_DATE , 70, 10, 65, 14, SS_CENTER + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000204
dialogitem 'STATIC','__:__:__' , ID_EDIT_TIME , 70, 30, 65, 14, SS_CENTER + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000204
dialogitem 'STATIC','__:__:__' , ID_EDIT_LOCAL , 70, 50, 65, 14, SS_CENTER + SS_CENTERIMAGE + WS_CHILD + WS_VISIBLE + WS_GROUP, 0x00000204
; button quit defined first (before time) with BS_DEFPUSHBUTTON value to give focus
dialogitem 'BUTTON','&Quit' , ID_BUTTON_QUIT, 80, 80, 60, 28, WS_VISIBLE+WS_TABSTOP+BS_DEFPUSHBUTTON ;BS_DEFPUSHBUTTON + BS_VCENTER + BS_CENTER + WS_CHILD + WS_VISIBLE + WS_TABSTOP
dialogitem 'BUTTON','&Time' , ID_BUTTON_TIME, 10, 80, 60, 28, WS_VISIBLE+WS_TABSTOP+BS_PUSHBUTTON ;BS_PUSHBUTTON + BS_VCENTER + BS_CENTER + WS_CHILD + WS_VISIBLE + WS_TABSTOP
enddialog
icon main_icon,icon_data,'nico.ico' ; mettez l'icone que vous voulez
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
.bat de sauvegarde date et heure [ par caviar ]
Salut ...je ne sais pas vraiment si c'est le bon forum pour cette question mais j'imagine ques c'est tellement simple pour vous que ce sera facile de
Manipulation Filetime [ par Bros ]
BonjourDans un petit programme, je parcours un répertoire avec des fichiers txt.Le but du soft est d'effacer les fichiers plus vieux que x jours.Donc,
include et fasm [ par CheckList ]
Bonjour, j'ai un probleme avec FASM. Voila, j'essaye de compilé un programme deja tout fait ecrit en FASM trouvez dans le repertoire exemple.Mon prob
macro pour definir des donnees avec FASM [ par Forthman ]
Bonjour, je me suis mis a FASM il y a peu, et j'aimerai savoir s'il était possible de simplifier un peu la saisie des données. Je dois me faire un t
fatal error LNK1190 [ par WildChild54 ]
Bonjour à tous!Eh bien voilà, je voudrais créer un petit programme affichant l'heure (je sais il y en a déjà plusieurs qui en ont parlé ici) mais j'ai
utiliser un pic 16f84 pour actionner un relais à une heures précise [ par ydelanick ]
Je suis dans un lycée technique et on nous à donné comme projet de réaliser le systeme que je vous décris. Je voudrais actionner un relais 12V-DC à l'
Fasm et MDI [ par frech ]
Bonjour.Je suis un debutant en Francais et en Assembly, et j'ai une question regard Win32API. J'aimerais planifier un IDE pour FASM, mais je ne peux
FASM, WinAPI et Japonais [ par frech ]
Bonjour.Je voudrais creer un quiz pour le langue japonais, mais je ne peux pas connaitre à sqlite ou modifier la légende d'un contrôle statique pour a
Création de DLL [ par HollowSpecter128 ]
Salut à tous!Je voudrais savoir si qq1 pourrais montrer comment on fè pour créer 1 DLL entièrement en assembleur sous NASM ou FASM.Quoique pour FASM j
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version

HTC G1
Entre 449€ et 449€
|