Conversion of common data types (constantly updating)

Source: Internet
Author: User
Tags filetime

In the process of program development, the conversion between different data is constantly encountered. Here is a summary:
I. Conversion between time types:
1. Convert time_t to FILETIME
FILETIME ft;
LONGLONG ll = Int32x32To64 (t, 10000000) + 116444736000000000;
Ft. dwLowDateTime = (DWORD) ll;
Ft. dwHighDateTime = (DWORD) (ll> 32 );

2. Convert FILETIME to time_t
FILETIME ft;
LONGLONG llTime;
Time_t t;
LlTime = (ft. dwHighDateTime <32) + ft. dwLowDateTime;

T = (DWORD) (LONGLONG) (Fig-116444736000000000)/10000000 );

3. SYSTEMTIME to FILETIME
FILETIME ft;
SYSTEMTIME st;
SystemTimeToFileTime (& st, & ft );

4. FILETIME to SYSTEMTIME
FILETIME ft;
SYSTEMTIME st;
FileTimeToSystemTime (& ft, & st );

5. Convert DATE to SYSTEMTIME
DATE pst;
SYSTEMTIME st;
VariantTimeToSystemTime (pst, & st );
6. Convert SYSTEMTIME to DATE
DATE pst;
SYSTEMTIME st;

SystemTimeToVariantTime (st, & pst );

7. BYTE to DWORD

# Define MAKEB2W (c0, c1, c2, c3) (DWORD) (BYTE) (c0) | (WORD) (BYTE) (c1 )) <8) | (DWORD) (BYTE) (c2) <16) | (DWORD) (BYTE) (c3 )) <24 )))

 


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.