Return to Snippet

Revision: 26184
at April 20, 2010 01:28 by liupengf12


Updated Code
FILETIME ft = new FILETIME();

//from System.DateTime to System.Runtime.InteropServices.ComTypes.FILETIME

/////////////////////////////////////////////////////////////////

long hFT1 = DateTime.Now.ToFileTime();

ft.dwLowDateTime = (int)(hFT1 & 0xFFFFFFFF);

ft.dwHighDateTime = (int)(hFT1 >> 32);

Revision: 26183
at April 20, 2010 01:26 by liupengf12


Initial Code
FILETIME ft = new FILETIME();

//from System.DateTime to System.Runtime.InteropServices.ComTypes.FILETIME

/////////////////////////////////////////////////////////////////

long hFT1 = DateTime.Now.ToFileTime();

ft.dwLowDateTime = (int)(hFT1 & 0xFFFFFFFF);

ft.dwHighDateTime = (int)(hFT1 >> 32);


/////////////////////////////////////////////////////////////////

//from System.Runtime.InteropServices.ComTypes.FILETIME to System.DateTime

/////////////////////////////////////////////////////////////////

long hFT2 = (((long)ft.dwHighDateTime) << 32) + ft.dwLowDateTime;

DateTime dte = DateTime.FromFileTime(hFT2);

Initial URL
http://windows-tech.info/1/dc66674e398c3e66.php

Initial Description


Initial Title
DateTime to FILETIME

Initial Tags


Initial Language
C#