Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than kernel32, prefix the name with the module name and a period.
public struct UFILETIME
{
public uint dwLowDateTime;
public uint dwHighDateTime;
}
Notes:
Sample and signature code originally used System.Runtime.InteropServices.FILETIME, but this uses ints instead of uints (DWORDs) meaning that this line:
long hFT2 = (((long) ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
gave incorrect results due to signs.
Tips & Tricks:
Please add some!
Alternate C# process:
[DllImport("kernel32", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
private static extern int DosDateTimeToFileTime(ushort dateValue, ushort timeValue, out UInt64 fileTime);
[DllImport("kernel32", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
private static extern int FileTimeToDosDateTime(ref UInt64 fileTimeInfo, out ushort dateValue, out ushort TimeValue);
void Test()
{
UInt64 data = Convert.ToUInt64(DateTime.Now.ToFileTime());
int result = 0;
ushort dateValue = 0;
ushort timeValue = 0;
result = FileTimeToDosDateTime(ref data, out dateValue, out timeValue);
data = 0;
result = DosDateTimeToFileTime(dateValue, timeValue, out data);
public struct UFILETIME
{
public uint dwLowDateTime;
public uint dwHighDateTime;
}
private static DateTime ConvertDosDateTime(ushort DosDate, ushort DosTime)
private static DateTime ConvertDosDateTime(short DosDate, short DosTime)
{
UFILETIME filetime = new UFILETIME();
DosDateTimeToFileTime(DosDate, DosTime, out filetime);
//Reference: http://www.aspemporium.com/howto.aspx?hid=26
long longfiletime = (long)(((ulong)filetime.dwHighDateTime << 32) +
(ulong)filetime.dwLowDateTime);
return DateTime.FromFileTimeUtc(longfiletime);
}
Alternative Managed API:
Do you know one? Please contribute it!
The DosDateTimeToFileTime API
10/9/2008 9:05:37 AM - -82.47.136.24
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).