Accueil > > > [FASM]-DATE ET HEURE
[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
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
Traduction MASM > FASM [ par ianis24 ]
Bonjour, J'ai commencer l'assembleur depuis un petit moment ( j'apprends lentement). J'utilise le compilateur FASM. Malheureusement pour moi beaucoup
|
Derniers Blogs
WP7 5K BELGIUM CHALLENGEWP7 5K BELGIUM CHALLENGE par junarnoalg
Microsoft Belgique a le plaisir de vous annoncer le lancement du
Challenge Windows Phone 7
. Celui-ci se déroule du 12 juillet au 30 novembre 2010 et vous donne l'opportunit...
Cliquez pour lire la suite de l'article par junarnoalg LES MONADES POUR LES NULSLES MONADES POUR LES NULS par mdufourneaudravel
Avec l'annonce de F#, je me suis intéressé de plus en plus à la programmation fonctionnelle, je suis donc rapidement tombé sur les " monades ", mais malgré la lecture de plusieurs articles, j'étais resté perméable à leur concept. C'est désormais fini, grâ...
Cliquez pour lire la suite de l'article par mdufourneaudravel [WP7] AJOUTER DES IMAGES DANS LA MEDIA LIBRARY D'UN WINDOWS PHONE 7[WP7] AJOUTER DES IMAGES DANS LA MEDIA LIBRARY D'UN WINDOWS PHONE 7 par Audrey
L'émulateur Windows Phone 7, fourni avec la version Beta des outils développeurs n'inclut aucune image dans sa bibliothèque. Pas très pratique de tester son application lorsque l'on souhaite que l'utilisateur puisse choisir une image présente dans le télé...
Cliquez pour lire la suite de l'article par Audrey VIVE LES MOCKS ET LES POCOSVIVE LES MOCKS ET LES POCOS par vLabz
J'observe régulièrement autour de moi de la confusion à propos de ces deux termes et j'aimerais juste rappeler ce qu'ils signifient. Je ne suis bien sûr pas le mieux placé pour faire une leçon mais je vais faire de mon mieux pour mettre en valeur ce q...
Cliquez pour lire la suite de l'article par vLabz [WF4] WORKFLOW AND CUSTOM ACTIVITIES - BEST PRACTICES (4/5)[WF4] WORKFLOW AND CUSTOM ACTIVITIES - BEST PRACTICES (4/5) par JeremyJeanson
Vendredi dernier Microsoft a publié le quatrième épisode des bonnes pratiques pour coder ses activités custom dans WF4 : endpoint.tv - Workflow and Custom Activities - Best Practices (Part 4) . Tout comme pour les précédents épisodes, j'ai pris le temps d...
Cliquez pour lire la suite de l'article par JeremyJeanson
Logiciels
Crystal Report (11)CRYSTAL REPORT (11)Crystal Reports est un outil de reporting souple et puissant, vous pouvez très facilement consult... Cliquez pour télécharger Crystal Report Academy System (12.0.2.0)ACADEMY SYSTEM (12.0.2.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft iPod Vidéo Convertisseur 6 (6.0.3.0419)XILISOFT IPOD VIDéO CONVERTISSEUR 6 (6.0.3.0419)Xilisoft iPod Vidéo Convertisseur est un outil puissant de conversion d'iPod, facile à utiliser. ... Cliquez pour télécharger Xilisoft iPod Vidéo Convertisseur 6 Xilisoft iPhone Vidéo Convertisseur 6 (6.0.3.0419)XILISOFT IPHONE VIDéO CONVERTISSEUR 6 (6.0.3.0419)Xilisoft iPhone Vidéo Convertisseur est le meilleur logiciel de conversion iPhone qui peut facile... Cliquez pour télécharger Xilisoft iPhone Vidéo Convertisseur 6 Xilisoft iPad Vidéo Convertisseur 6 (6.0.3.0419)XILISOFT IPAD VIDéO CONVERTISSEUR 6 (6.0.3.0419)Il s'agit d'un logiciel polyvalent pour convertir les formats vidéo/audio populaires en formats p... Cliquez pour télécharger Xilisoft iPad Vidéo Convertisseur 6
|