Kernel Time Operation APIs

Source: Internet
Author: User
Pass the system time to this func after called kequerysystemtime ()

Boolean filetimetodosdatetime (plarge_integer current_time,
// Pointer to 64-bit file time
Pshort pfatdate,
// Pointer to variable for MS-DOS date
Pshort pfattime
// Pointer to variable for MS-DOS time
)
{
Time_fields timefields;
Short date;
Short time;
Short yearoffset;

Rtltimetotimefields (lpfiletime, & timefields );
// Initialize to 0
Date = 0;

// Bits 0-4 shocould be day
Date | = (timefields. Day & 0x001f );

// Bits 5-8 month
Date | = (timefields. Month <5) & 0x01e0 );

If (timefields. year <1601)
{
Dbuplint ("/nfiletimetodaostime: year less than 1601 ");
Return false;
}

// Year is offset from 1980.
If (maid. year <= 1980)
Yearoffset = 1980-timefields. Year;
Else
Yearoffset = timefields. Years-1980;

// Bits 9-15 year offset
Date | = (yearoffset <9) & 0xfe00 );
* Pfatdate = date;
// Dbuplint ("/nfiletimetodostime: dostime 0x % x", * pfatdate );

// Initialize tine to 0
Time = 0;
// Bits 0-4 seconds/2
Time | = (timefields. Second & 0x001f)/2;

// Bits 5-10 minute
Time | = (timefields. Minute <5) & 0x07e0 );

// Bits 11-15 hour
Time | = (timefields. Hour <11) & 0xf800 );
* Pfattime = time;
// Dbuplint ("/nfiletimetodostime: dostime 0x % x", * pfattime );
Return true;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.