예제 #1
0
파일: IE.cs 프로젝트: mohamadpk/Monitoring
 /// <summary>
 /// Filetimes to long.
 /// </summary>
 /// <param name="ft">The ft.</param>
 /// <returns>the file time is important for microsoft ie history because create time of history is create time of that file</returns>
 private static DateTime FILETIMEToLong(System.Runtime.InteropServices.FILETIME ft)
 {
     try {
         ulong high     = (ulong)ft.dwHighDateTime;
         uint  low      = (uint)ft.dwLowDateTime;
         long  fileTime = (long)((high << 32) + low);
         return(DateTime.FromFileTimeUtc(fileTime));
     }
     catch (Exception ex)
     {
         var epoch = new DateTime(1, 1, 1, 0, 0, 0, DateTimeKind.Utc);
         return(epoch);
     }
 }
예제 #2
0
        public static DateTime ToDateTime(this System.Runtime.InteropServices.FILETIME time)
        {
            long     hFT2 = (((long)time.dwHighDateTime) << 32) + time.dwLowDateTime;
            DateTime dte  = DateTime.FromFileTime(hFT2);

            return(dte);

            //ulong high = (ulong)time.dwHighDateTime;
            //uint low = (uint)time.dwLowDateTime;
            //long fileTime = (long)((high << 32) + low);
            //try
            //{
            //    return DateTime.FromFileTimeUtc(fileTime);
            //}
            //catch
            //{
            //    return DateTime.FromFileTimeUtc(0xFFFFFFFF);
            //}
        }
예제 #3
0
 internal static extern int MsiSummaryInfoGetProperty(uint summaryInfo, int property, out uint dataType, out int integerValue, ref FILETIME fileTimeValue, StringBuilder stringValueBuf, ref int stringValueBufSize);
예제 #4
0
 /// <summary>
 /// Update the file times on the given file handle.
 /// </summary>
 public static unsafe void SetFileCreationTime(SafeFileHandle hFile, DateTime creationTime)
 {
     FILETIME fileCreationTime = new FILETIME(creationTime.ToFileTimeUtc());
     if (!SetFileTime(hFile, &fileCreationTime, null, null)) {
         throw new Win32Exception(Marshal.GetLastWin32Error());
     }
 }
예제 #5
0
 internal static extern bool LocalFileTimeToFileTime(
     FILETIME lpLocalFileTime, // _In_   const FILETIME *
     FILETIME lpFileTime); // _Out_  LPFILETIME 
예제 #6
0
 public static extern void GetSystemTimeAsFileTime(FILETIME *lpSystemTimeAsFileTime);
예제 #7
0
 internal static OpcRcw.Ae.FILETIME Convert(System.Runtime.InteropServices.FILETIME input)
 {
     return(new OpcRcw.Ae.FILETIME {
         dwLowDateTime = input.dwLowDateTime, dwHighDateTime = input.dwHighDateTime
     });
 }
예제 #8
0
 public static extern bool ReadTagWithTimeStamp(UInt32 TagHandle, ref Object Value, ref UInt16 Quality, ref FILETIME Timestamp);
예제 #9
0
 public static extern bool ConvertFileTimeToVBDate1(ref FILETIME FileTime, ref double VBDate);
예제 #10
0
   public static extern void LookupHistoryAssembly(
 string pwzFilePath,
 ref FILETIME pftActivationDate,
 string pwzAsmName,
 string pwzPublicKeyToken, 
 string wzCulture,
 string pwzVerRef,
 out IntPtr pHistAsm);
예제 #11
0
파일: Yellows.cs 프로젝트: Makk24/QZone
 private string FILETIMEtoDataTime(FILETIME time)
 {
     IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(FILETIME)));
     IntPtr intPtr2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Yellows.SYSTEMTIME)));
     Marshal.StructureToPtr(time, intPtr, true);
     Yellows.FileTimeToSystemTime(intPtr, intPtr2);
     Yellows.SYSTEMTIME sYSTEMTIME = (Yellows.SYSTEMTIME)Marshal.PtrToStructure(intPtr2, typeof(Yellows.SYSTEMTIME));
     return string.Concat(new string[]
     {
         sYSTEMTIME.wYear.ToString(),
         ".",
         sYSTEMTIME.wMonth.ToString(),
         ".",
         sYSTEMTIME.wDay.ToString(),
         ".",
         sYSTEMTIME.wHour.ToString(),
         ".",
         sYSTEMTIME.wMinute.ToString(),
         ".",
         sYSTEMTIME.wSecond.ToString()
     });
 }
예제 #12
0
 public static extern bool FileTimeToLocalFileTime([In] ref FILETIME lpFileTime, out FILETIME lpLocalFileTime);
예제 #13
0
파일: Kernel.cs 프로젝트: labeuze/source
		[DllImport("kernel32")] public static extern int SystemTimeToFileTime(ref User.Struct.SYSTEMTIME lpSystemTime, ref FILETIME lpFileTime);
예제 #14
0
파일: Kernel.cs 프로젝트: labeuze/source
		[DllImport("kernel32")] public static extern int SetFileTime(HANDLE hFile, ref FILETIME lpCreationTime, ref FILETIME lpLastAccessTime, ref FILETIME lpLastWriteTime);
예제 #15
0
 public static extern long FileTimeToSystemTime(ref FILETIME FileTime, ref SYSTEMTIME SystemTime);
예제 #16
0
파일: Kernel.cs 프로젝트: labeuze/source
		[DllImport("kernel32")] public static extern int LocalFileTimeToFileTime(ref FILETIME lpLocalFileTime, ref FILETIME lpFileTime);
예제 #17
0
 internal static extern uint MsiSummaryInfoSetProperty(IntPtr summaryInfo, int property, uint dataType, int integerValue, ref FILETIME fileTimeValue, string stringValue);
예제 #18
0
 public static extern bool ConvertVBDateToFileTime1(ref double VBDate, ref FILETIME FileTime);
예제 #19
0
 /// <summary>
 /// Converts a file time to DateTime format.
 /// </summary>
 /// <param name="filetime">FILETIME structure</param>
 /// <returns>DateTime structure</returns>
 public static DateTime FileTimeToDateTime(FILETIME filetime)
 {
     SYSTEMTIME st = new SYSTEMTIME();
     FileTimeToSystemTime(ref filetime, ref st);
     return new DateTime(st.Year, st.Month, st.Day, st.Hour , st.Minute, st.Second, st.Milliseconds);
 }
예제 #20
0
 static extern bool FileTimeToSystemTime(ref FILETIME FileTime, ref SYSTEMTIME SystemTime);
예제 #21
0
        static extern bool SystemTimeToFileTime([In] ref SYSTEMTIME lpSystemTime, 
			out FILETIME lpFileTime);
예제 #22
0
 public static extern bool GetFileTime(HandleRef hFile, out FILETIME *lpCreationTime, out FILETIME *lpLastAccessTime, out FILETIME *lpLastWriteTime);
예제 #23
0
        /// <summary>
        /// Sets the date and time, in local time, that the file was last updated or written to.</summary>
        /// <param name="path">The file for which to set the creation date and time information.</param>
        /// <param name="lastWriteTime">A DateTime containing the value to set for the last write date and time of path. This value is expressed in local time.</param>
        public static void SetLastWriteTime(string path, DateTime lastWriteTime)
        {
            FILETIME ft;
            IntPtr hFile = IntPtr.Zero;

            if (path == null)
                throw new ArgumentNullException();

            if (path.Length > 260)
                throw new PathTooLongException();

            if (path.Trim().Length == 0)
                throw new ArgumentException();

            hFile = CreateFile(path, FileAccess.Write, FileShare.Write, FileCreateDisposition.OpenExisting, 0);

            if ((int) hFile == InvalidHandle)
            {
                int e = Marshal.GetLastWin32Error();
                if ((e == 2) || (e == 3))
                {
                    throw new FileNotFoundException();
                }
                else
                {
                    throw new Exception("Unmanaged Error: " + e);
                }
            }

            ft = new FILETIME(lastWriteTime.ToFileTime());

            SetFileTime(hFile, null, ft, null);

            CloseHandle(hFile);
        }
예제 #24
0
 internal static extern bool DosDateTimeToFileTime(
     short wFatDate, // _In_   WORD
     short wFatTime, // _In_   WORD
     FILETIME lpFileTime); // _Out_  LPFILETIME 
예제 #25
0
 public static extern bool UpdateTagWithTimeStamp(UInt32 TagHandle, Object Value, UInt16 Quality, FILETIME timestamp);
예제 #26
0
 internal static extern bool SetFileTime(
     IntPtr hFile, // _In_      HANDLE
     FILETIME lpCreationTime, // _In_opt_  const FILETIME *
     FILETIME lpLastAccessTime, // _In_opt_  const FILETIME *
     FILETIME lpLastWriteTime); // _In_opt_  const FILETIME *
예제 #27
0
 public static extern bool UpdateTagWithTimeStampByName([MarshalAs(UnmanagedType.LPStr)] String Name, Object Value, FILETIME TimeStamp, UInt16 Quality);
예제 #28
0
 static unsafe extern bool SetFileTime(SafeFileHandle hFile, FILETIME* creationTime, FILETIME* lastAccessTime, FILETIME* lastWriteTime);
예제 #29
0
 public static extern bool UpdateTagWithTimeStampToList(UInt32 TagHandle, Object Value, FILETIME TimeStamp, UInt16 Quality);
예제 #30
0
 public void SetElementTimes(string pwcsName, FILETIME[] pctime, FILETIME[] patime, FILETIME[] pmtime)
 {
 }
예제 #31
0
 public static extern bool VBCreateFileTime(UInt16 Year,
     UInt16 Month,
     UInt16 Day,
     UInt16 Hour,
     UInt16 Minute,
     UInt16 Second,
     UInt16 Milliseconds,
     ref FILETIME FileTime);
예제 #32
0
			internal void From(NativeMethods.WIN32_FIND_DATA findData)
			{
				fileAttributes = findData.dwFileAttributes;
				ftCreationTime = findData.ftCreationTime;
				ftLastAccessTime = findData.ftLastAccessTime;
				ftLastWriteTime = findData.ftLastWriteTime;
				fileSizeHigh = findData.nFileSizeHigh;
				fileSizeLow = findData.nFileSizeLow;
			}
예제 #33
0
파일: Kernel.cs 프로젝트: labeuze/source
		[DllImport("kernel32")] public static extern int GetThreadTimes(HANDLE hThread, ref FILETIME lpCreationTime, ref FILETIME lpExitTime, ref FILETIME lpKernelTime, ref FILETIME lpUserTime);