SYSTEMTIME FileTimeToLocalFileTime 使用

来源:互联网 发布:mac卸载java 8 编辑:程序博客网 时间:2024/06/05 17:40

有时候SYSTEMTIME获取时间值是在协调世界时(UTC)格式,比如说北京时间为上午10:00,可能通过我们的代码获取到的时候为凌晨1-2点,这个时间就是UCT的格式,所以需要转换为本地时间,转换为本地时间需要用到FileTimeToLocalFileTime,看下参数,

BOOL WINAPI FileTimeToLocalFileTime(  __in          const FILETIME* lpFileTime,  __out         LPFILETIME lpLocalFileTime);
lpFileTime
A pointer to a FILETIME structure containing the UTC-based file time to be converted into a local file 
//一个指向包含要转换成一个本地文件时间基于UTC的文件时间FILETIME结构。
lpLocalFileTime
A pointer to a FILETIME structure to receive the converted local file time. This parameter cannot be the same as the lpFileTime parameter.
//一个指针,指向一个FILETIME结构,以接收转换本地文件的时间。这个参数可以是不一样的lpFileTime参数。
具体使用如下:
      SYSTEMTIME st;      FILETIME localft;      FILETIME lpFileTime;      /*      ......  获取SYSTEMTIME      /*      SystemTimeToFileTime(&st,&localft);    //第一步 将SYSTEMTIME 转换 FILETIME      FileTimeToLocalFileTime(&localft,&lpFileTime);  //第二步 将FILETIME转换为本地时间      FileTimeToSystemTime(&lpFileTime,&st); //第三步 将FILETIME转换为SYSTEMTIME


0 0
原创粉丝点击