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
[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA par cyril
Le deuxième keynote du mix fut très riche en contenu. Internet Explorer 9 Juste un après le lancement de Internet Explorer 8, Microsoft a dévoilé les nouveautés de Internet Explorer 9. Désormais, IE supportera HTML5, SVG et CSS3. L'élément ...
Cliquez pour lire la suite de l'article par cyril CERTIFICATIONS BETA .NET 4CERTIFICATIONS BETA .NET 4 par KooKiz
Les inscriptions pour les certifications beta .NET 4 ont commencé. L'inscription est offerte pour les examens suivants : - 71-511, TS: Windows Applications Development with Microsoft .NET Framework 4 - 71-515, TS: Web Applications Development with...
Cliquez pour lire la suite de l'article par KooKiz [MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2[MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2 par redo
J'imagine que la plupart d'entre vous connaissent bien et utilisent le service de traduction de Google, mais connaissez-vous celui de Microsoft . Microsoft Translator ? Effectivement, Microsoft nous annoncé le lancement version 2 de la Technologie Preview...
Cliquez pour lire la suite de l'article par redo LANCEMENT EN PREVIEW DE CYCLONE LORS DES TECHDAYS 2010!LANCEMENT EN PREVIEW DE CYCLONE LORS DES TECHDAYS 2010! par MPOWARE
Toutes les vidéos de ce lancement sont en ligne!
Partie I - Intro
http://www.youtube.com/watch?v=LkQzTQ8T6CA
Partie II - Démo 1
http://www.youtube.com/watch?v=drAhYQ7lqvo
Partie III - Démo 2
http://www.youtube.com/watch?v=c8KM_1Gqybc...
Cliquez pour lire la suite de l'article par MPOWARE [WP7] JE NE VEUX PAS D'UN NOUVEL IPHONE[WP7] JE NE VEUX PAS D'UN NOUVEL IPHONE par FREMYCOMPANY
Je pense qu'ils ont besoin d'une piqure de rappel chez Microsoft : c'est bien gentil d'avoir une interface jolie, mais si c'est pour avoir un truc qui ne convainct pas dedans, c'est peine perdue.
---->
Système ouvert ----> Fermé ?
P...
Cliquez pour lire la suite de l'article par FREMYCOMPANY
Forum
RE : CSHARPRE : CSHARP par ghuysmans99
Cliquez pour lire la suite par ghuysmans99
Logiciels
Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods Konvertor (4.00)KONVERTOR (4.00)Le logiciel est un gestionnaire multimedia affichant, jouant et convertissant plus de 2000 format... Cliquez pour télécharger Konvertor
|