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
TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Arnault Nouvel et Antoine Dongois Le processus à prendre : Apprendre (découvrir la plateforme) Préparer (documenter l'historique et choisir la méthode de MAJ) Test (Test de MAJ) Implémenter (Effectuer la MAJ) Valid...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
RE : PIC 16F84RE : PIC 16F84 par pont
Cliquez pour lire la suite par pont RE : PIC 16F84RE : PIC 16F84 par belounis
Cliquez pour lire la suite par belounis RE : PIC 16F84RE : PIC 16F84 par pont
Cliquez pour lire la suite par pont
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|