FILETIME 互转 DateTime 待验证
来源:互联网 发布:淘宝店铺客服中心图片 编辑:程序博客网 时间:2024/06/16 13:22
http://blog.163.com/mingwang_ok/blog/static/18436570200773075452554/
HOW TO: convert a System.Runtime.InteropServices.FILETIME into a System.DateTime and back again
Added On: 12/14/2003Blurb
Eventually, everyone works with an unmanaged Win32 API in .NET that returns you information in the form of a FILETIME struct. But, a .NET programmer is used to working with a DateTime struct. This code converts FILETIME to DateTime and DateTime to FILETIME... just everything a growing programmer needs.
Sample C# Code
using System;using System.Runtime.InteropServices;namespace ClassLibrary3{ class __Loader { // HOWTO: convert a System.Runtime.InteropServices.FILETIME // into a System.DateTime and back again static void Main() { FILETIME ft = new FILETIME(); ///////////////////////////////////////////////////////////////// //from System.DateTime to System.Runtime.InteropServices.FILETIME ///////////////////////////////////////////////////////////////// long hFT1 = DateTime.Now.ToFileTimeUtc(); ft.dwLowDateTime = (int) (hFT1 & 0xFFFFFFFF); ft.dwHighDateTime = (int) (hFT1 >> 32); ///////////////////////////////////////////////////////////////// //from System.Runtime.InteropServices.FILETIME to System.DateTime ///////////////////////////////////////////////////////////////// long hFT2 = (((long) ft.dwHighDateTime) << 32) + ft.dwLowDateTime; DateTime dte = DateTime.FromFileTimeUtc(hFT2); Console.WriteLine(dte); } }}
阅读全文
0 0
- FILETIME 互转 DateTime 待验证
- FILETIME
- FILETIME
- 待验证
- 待验证
- Windows FILETIME与JAVA Date互转
- 待验证 bot
- opencv实现yuv420与bgr24互转,待验证
- oracle碎片小结(待验证)
- ubuntu安装bugzilla。--待验证。
- java验证码--待抽象
- 关于一些待验证的
- redis 主从复制 【待验证】
- 待验证设想(1)
- 远程唤醒(待验证)
- 关于FILETIME
- FILETIME 结构
- 验证MS关于DateTime的JSON表示
- 决策树之信息增益计算模拟
- Test_Java_File类递归练习(按层级打印)
- 【PAT】【Advanced Level】1084. Broken Keyboard (20)
- cookie实现自动登陆原理
- JavaEE之Maven中的pom.xml文件jar包dependency配置方法
- FILETIME 互转 DateTime 待验证
- Java 8 reduce()方法快速使用入门
- Java利用MessageDigest获取字符串或文件MD5详解
- 判断json指定的值是否为空
- Java基础数组
- ElasticSearch Java api 详解_V1.0
- oracle中的exists和not exists的用法总结
- 打印机端口检测(minotr port)安装
- ffmpeg处理RTMP流媒体的命令大全