本文代码来自于《Intel汇编语言程序设计》(第四版)第11章---------32位windows编程。
GetDateTime其实是作者Irvine32库文件中的一个函数,它用来返回一个64位的整数,这个数值是自1601年1月1日开始的以100纳秒为单位的计数值。重要的是微软使用这个数值来作为文件的日期和时间。WIN32 SDK文档中给出的获得系统日期和时间的步骤如下:
1.调用一个函数(例如GetLocalTime)来填写SYSTEMTIME结构。
2.用SystemTimeToFileTime函数来讲SYSTEMTIME结构转换到FILETIME结构。
3.将FILETIME结构中的结果拷贝到一个64位的QWORD中。
其中FILETIME结构将一个64位的QWORD值划分为2个DWORD值:
FILETIME STRUCT
loDateTime DWORD ?
hiDateTime DWORD ?
FILETIME ENDS
下面是GetDateTime函数代码:
;------------------------------------------------------------------------------------
GetDateTime PROC
pStartTime : PTR QWORD ; 程序接收一个指向QWORD的指针
LOCAL sysTime : SYSTEMTIME , fileTime : FILETIME ; 程序定义了两个局部变量,分别是SYSTEMTIME 类型和FILETIME 类型
;
; Gets and saves the current local date/time as a
; 64-bit integer ( in the Win32 FILETIME format).
;------------------------------------------------------------------------------------
; Get the system local time
INVOKE GetLocalTime , ; 按照微软的建议,先得到一个时间,将它填充到SYSTEMTIME 结构中
ADDR sysTime
; Convert the SYSTEMTIME to FILETIME
INVOKE SystemTimeToFileTime, ; 然后又按照微软的建议,将SYSTEMTIME 结构中的内容填充到FILETIME结构中
ADDR sysTime, ; SYSTEMTIME 结构
ADDR flTime ; FILETIME 结构
; Copy the FILETIME to a 64-bit integer
mov esi , pStartTime ; 然后我们再按照微软的建议执行第三步,这里先得到这个64位QWORD的地址
mov eax , flTime.loDateTime ; 将FILETIME 结构中的loDateTime段赋给eax
mov DWORD PTR [esi] , eax ; 讲eax 赋值到64位的pStartTime的低4字节中
mov eax , flTime.hiDateTime ; 将FILETIME 结构中的hiDateTime段赋给eax
mov DWORD PTR [esi+4] , eax ; 讲eax 赋值到64位的pStartTime的高4字节中
ret ; 按照微软的建议,我们得到了日期和时间,返回主函数
GetDateTime ENDP
代码结束。
分享到:
相关推荐
开发语言:ASP 版 权:支付宝()网络技术有限公司 制 作 者:支付宝技术部技术支持组 联系方式:https://support.open.alipay.com/alipay/support/index.htm 免责声明:DEMO仅供参考,实际开发中需要结合具体...
public String getDatetime() { return Date; } public float getOpenPrice() { return Open; } public float getHighPrice() { return High; } public float getLowPrice() { return Low; } ...
测试作业00 尝试测试作业00 ...getDateTime(): 2015-05-30T20:00 getDate(): 2015-05-30 getDateTime(): 2015-05-30T20:00 getDateTime(): 2015-05-31T10:00 getDate(): 2015-05-31 getDateTime(): 2015-05-31T1
相关代码如下: procedure TForm1.SpeedButton1Click(Sender: TObject); begin if OpenDialog1.Execute then begin Edit1.Text := OpenDialog1.FileName; Edit2.Text := ''; end; end; procedure ...
// default 1st Jan 2021 00:00:00getTime() // (String) 15:24:38getDate() // (String) Sun, Jan 17 2021getDate(true) // (String) Sunday, January 17 2021getDateTime() // (String) Sun, Jan
用GetDateTime(COleDateTime& dateSrc)来获取编辑框中的内容 用SetDateTime(COleDateTime& dateSrc)来设置编辑框中的内容 用ClearDateTime(COleDateTime& dateSrc)来清除编辑框中的内容 可以EnableWindow(BOOL ...
能满足初学者的需要,代码理解不难.for (int i = 1; i ; i++) { string[] arrRets = PopMail(tcpclient, i); Email.POP3.EmailMessage objEmail = objPOP3.GetMessage(i, false); richEmailsInfo.AppendText("=...
JavaScript,时间格式化...vue : 使用es6 引入 getDateTime( time,'yyyy-M-d' ) 第一个是 时间 戳 第二个是 需要的 时间格式 注释 : 格式为:fromDate fromDate 参数为时间格式 time : 组件调用传过来的时间格式
res.Dob = reader.GetDateTime(4); res.State = reader.GetString(5); return res; } class Individual : IIndividual { public int ID { get; set; } public string FirstName { get; set; } public ...
//初始化RTC void jdev_rtc_init(void); //校正RTC轮询,成功返回校准值,输入校准值则直接校准 unsigned char j_rtc_do(unsigned char jrtc... void j_getdatetime(void); //设置时间 void j_setdatetime(void);
一个智能化的日期时间类CDateTimeEidt 这个类虽然是从CEdit类...用GetDateTime(COleDateTime& dateSrc)来获取编辑框中的内容 用SetDateTime(COleDateTime& dateSrc)来设置编辑框中的内容 可以EnableWindow()来允许或
可空类型用途主要是从数据库读取数据有可能为空,而不是插入...)reader.GetDateTime(5); 判断取出的数据是否为数据库中的null,如果是则赋值给可空的int类型的Testint 属性 tseat.Testint = reader.IsDBNull(6) ? null