当前位置: 首页>>代码示例>>C#>>正文


C# FILETIME类代码示例

本文整理汇总了C#中FILETIME的典型用法代码示例。如果您正苦于以下问题:C# FILETIME类的具体用法?C# FILETIME怎么用?C# FILETIME使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FILETIME类属于命名空间,在下文中一共展示了FILETIME类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetLastWriteTime

            public static DateTime GetLastWriteTime(int hive, String subkey)
            {
                UIntPtr hKey = UIntPtr.Zero;
                int result = RegOpenKeyEx(hive, subkey, 0, KEYREAD, ref hKey);
                if (result != 0) {
                throw new System.ComponentModel.Win32Exception(result);
                }

                StringBuilder lpClass = new StringBuilder(1024);
                IntPtr lpcbClass = IntPtr.Zero;
                IntPtr lpReserved = IntPtr.Zero;
                uint lpcSubKeys;
                uint lpcbMaxSubKeyLen;
                uint lpcbMaxClassLen;
                uint lpcValues;
                uint lpcbMaxValueNameLen;
                uint lpcbMaxValueLen;
                uint lpcbSecurityDescriptor;
                FILETIME lastWriteTime = new FILETIME();
                result = RegQueryInfoKey(hKey, out lpClass, ref lpcbClass, lpReserved, out lpcSubKeys, out lpcbMaxSubKeyLen,
                     out lpcbMaxClassLen, out lpcValues, out lpcbMaxValueNameLen, out lpcbMaxValueLen,
                     out lpcbSecurityDescriptor, ref lastWriteTime);
                RegCloseKey(hKey);
                if (result != 0) {
                throw new System.ComponentModel.Win32Exception(result);
                }

                byte[] high = BitConverter.GetBytes(lastWriteTime.HighDateTime);
                byte[] low = BitConverter.GetBytes(lastWriteTime.LowDateTime);
                byte[] buff = new byte[high.Length + low.Length];
                Buffer.BlockCopy(low, 0, buff, 0, low.Length );
                Buffer.BlockCopy(high, 0, buff, low.Length, high.Length );
                long time = BitConverter.ToInt64(buff, 0);
                return DateTime.FromFileTimeUtc(time);
            }
开发者ID:praveeds,项目名称:jOVAL,代码行数:35,代码来源:Registry.cs

示例2: FiletimeToDateTime

        public static DateTime FiletimeToDateTime(FILETIME fileTime)
        {
            if ((fileTime.dwHighDateTime == Int32.MaxValue) ||
                (fileTime.dwHighDateTime == 0 && fileTime.dwLowDateTime == 0))
            {
                // Not going to fit in the DateTime.  In the WinInet APIs, this is
                // what happens when there is no FILETIME attached to the cache entry.
                // We're going to use DateTime.MinValue as a marker for this case.
                return DateTime.MaxValue;
            }
            //long hFT2 = (((long)fileTime.dwHighDateTime) << 32) + fileTime.dwLowDateTime;
            //return DateTime.FromFileTimeUtc(hFT2);

            SYSTEMTIME syst = new SYSTEMTIME();
            SYSTEMTIME systLocal = new SYSTEMTIME();
            if (0 == FileTimeToSystemTime(ref fileTime, ref syst))
            {
                throw new ApplicationException("Error calling FileTimeToSystemTime: " + Marshal.GetLastWin32Error().ToString());
            }
            if (0 == SystemTimeToTzSpecificLocalTime(IntPtr.Zero, ref syst, out systLocal))
            {
                throw new ApplicationException("Error calling SystemTimeToTzSpecificLocalTime: " + Marshal.GetLastWin32Error().ToString());
            }
            return new DateTime(systLocal.Year, systLocal.Month, systLocal.Day, systLocal.Hour, systLocal.Minute, systLocal.Second);
        }
开发者ID:CharlesZHENG,项目名称:csexwb2,代码行数:25,代码来源:WinApis.cs

示例3: GetFileTime

 public static extern int GetFileTime(HANDLE hFile, ref FILETIME lpCreationTime, ref FILETIME lpLastAccessTime, ref FILETIME lpLastWriteTime);
开发者ID:usbhell,项目名称:flurrysharp,代码行数:1,代码来源:Kernel.cs

示例4: FileTimeToSystemTime

 public static extern Boolean FileTimeToSystemTime(ref FILETIME lpFileTime, 
     out SYSTEMTIME lpSystemTime);
开发者ID:AndrewEastwood,项目名称:desktop,代码行数:2,代码来源:winapi.func.cs

示例5: CertGetCertificateChain

 private static extern unsafe bool CertGetCertificateChain(IntPtr hChainEngine, SafeCertContextHandle pCertContext, FILETIME* pTime, SafeCertStoreHandle hStore, [In] ref CERT_CHAIN_PARA pChainPara, CertChainFlags dwFlags, IntPtr pvReserved, out SafeX509ChainHandle ppChainContext);
开发者ID:johnhhm,项目名称:corefx,代码行数:1,代码来源:Interop.crypt32.cs

示例6: GetThreadTimes

 public static extern int GetThreadTimes(IntPtr hThread, ref FILETIME lpCreationTime, ref FILETIME lpExitTime,
                                         ref FILETIME lpKernelTime, ref FILETIME lpUserTime);
开发者ID:luowei98,项目名称:RobertLw,代码行数:2,代码来源:Kernel.cs

示例7: SetFileTime

 public static extern int SetFileTime(IntPtr hFile, ref FILETIME lpCreationTime, ref FILETIME lpLastAccessTime,
                                      ref FILETIME lpLastWriteTime);
开发者ID:luowei98,项目名称:RobertLw,代码行数:2,代码来源:Kernel.cs

示例8: CompareFileTime

 public static extern int CompareFileTime(ref FILETIME lpFileTime1, ref FILETIME lpFileTime2);
开发者ID:luowei98,项目名称:RobertLw,代码行数:1,代码来源:Kernel.cs

示例9: FileTimeToDosDateTime

 public static extern int FileTimeToDosDateTime(ref FILETIME lpFileTime, ref int lpFatDate, ref int lpFatTime);
开发者ID:luowei98,项目名称:RobertLw,代码行数:1,代码来源:Kernel.cs

示例10: SetFileTime

		[DllImport("kernel32", CharSet = CharSet.Unicode)] public static extern int SetFileTime(HANDLE hFile, ref FILETIME lpCreationTime, ref FILETIME lpLastAccessTime, ref FILETIME lpLastWriteTime);
开发者ID:santosh-mnrec,项目名称:rsync.net,代码行数:1,代码来源:Kernel.cs

示例11: SystemTimeToFileTime

		[DllImport("kernel32", CharSet = CharSet.Unicode)] public static extern int SystemTimeToFileTime(ref SYSTEMTIME lpSystemTime, ref FILETIME lpFileTime);
开发者ID:santosh-mnrec,项目名称:rsync.net,代码行数:1,代码来源:Kernel.cs

示例12: FileTimeToDosDateTime

		[DllImport("kernel32", CharSet = CharSet.Unicode)] public static extern int FileTimeToDosDateTime(ref FILETIME lpFileTime, ref int lpFatDate, ref int lpFatTime);
开发者ID:santosh-mnrec,项目名称:rsync.net,代码行数:1,代码来源:Kernel.cs

示例13: FileTimeToLocalFileTime

		[DllImport("kernel32", CharSet = CharSet.Unicode)] public static extern int FileTimeToLocalFileTime(ref FILETIME lpFileTime, ref FILETIME lpLocalFileTime);
开发者ID:santosh-mnrec,项目名称:rsync.net,代码行数:1,代码来源:Kernel.cs

示例14: DateTime2FileTime

 internal static FILETIME DateTime2FileTime(DateTime dateTime)
 {
     long fileTime = 0;
     if (dateTime != DateTime.MinValue)      //Checking for MinValue
         fileTime = dateTime.ToFileTime();
     FILETIME resultingFileTime = new FILETIME();
     resultingFileTime.dwLowDateTime = (uint)(fileTime & 0xFFFFFFFF);
     resultingFileTime.dwHighDateTime = (uint)(fileTime >> 32);
     return resultingFileTime;
 }
开发者ID:schraubchen,项目名称:BITSDL,代码行数:10,代码来源:Utils.cs

示例15: FileTime2DateTime

        internal static DateTime FileTime2DateTime(FILETIME fileTime)
        {
            if (fileTime.dwHighDateTime == 0 && fileTime.dwLowDateTime == 0)    //Checking for MinValue
                return DateTime.MinValue;

            long dateTime = (((long)fileTime.dwHighDateTime) << 32) + fileTime.dwLowDateTime;
            return DateTime.FromFileTime(dateTime);
        }
开发者ID:schraubchen,项目名称:BITSDL,代码行数:8,代码来源:Utils.cs


注:本文中的FILETIME类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。