首页 > 代码库 > 一种GetTickCount64实现
一种GetTickCount64实现
unit uGetTickCount64; interface uses windows; function _GetTickCount64(): Int64; implementation type LARGE_INTEGER = record lowpart :integer ; highpart :integer; end; PVOID=Pointer; _SYSTEM_INFORMATION_CLASS = ( SystemBasicInformation, SystemProcessorInformation, SystemPerformanceInformation, SystemTimeOfDayInformation, SystemNotImplemented1, SystemProcessesAndThreadsInformation, SystemCallCounts, SystemConfigurationInformation, SystemProcessorTimes, SystemGlobalFlag, SystemNotImplemented2, SystemModuleInformation, SystemLockInformation, SystemNotImplemented3, SystemNotImplemented4, SystemNotImplemented5, SystemHandleInformation, SystemObjectInformation, SystemPagefileInformation, SystemInstructionEmulationCounts, SystemInvalidInfoClass1, SystemCacheInformation, SystemPoolTagInformation, SystemProcessorStatistics, SystemDpcInformation, SystemNotImplemented6, SystemLoadImage, SystemUnloadImage, SystemTimeAdjustment, SystemNotImplemented7, SystemNotImplemented8, SystemNotImplemented9, SystemCrashDumpInformation, SystemExceptionInformation, SystemCrashDumpStateInformation, SystemKernelDebuggerInformation, SystemContextSwitchInformation, SystemRegistryQuotaInformation, SystemLoadAndCallImage, SystemPrioritySeparation, SystemNotImplemented10, SystemNotImplemented11, SystemInvalidInfoClass2, SystemInvalidInfoClass3, SystemTimeZoneInformation, SystemLookasideInformation, SystemSetTimeSlipEvent, SystemCreateSession, SystemDeleteSession, SystemInvalidInfoClass4, SystemRangeStartInformation, SystemVerifierInformation, SystemAddVerifier, SystemSessionProcessesInformation); SYSTEM_INFORMATION_CLASS = _SYSTEM_INFORMATION_CLASS; TSystemInformationClass = SYSTEM_INFORMATION_CLASS; _SYSTEM_TIME_OF_DAY_INFORMATION = record // Information Class 3 BootTime: LARGE_INTEGER; CurrentTime: LARGE_INTEGER; TimeZoneBias: LARGE_INTEGER; CurrentTimeZoneId: ULONG; end; SYSTEM_TIME_OF_DAY_INFORMATION = _SYSTEM_TIME_OF_DAY_INFORMATION; PSYSTEM_TIME_OF_DAY_INFORMATION = ^SYSTEM_TIME_OF_DAY_INFORMATION; function NtQuerySystemInformation( SystemInformationClass: SYSTEM_INFORMATION_CLASS; SystemInformation: PVOID; SystemInformationLength: ULONG; ReturnLength: PULONG ): Integer; stdcall; external ‘ntdll.dll‘; function NtQuerySystemTime( var CurrentTime: LARGE_INTEGER ): Integer; stdcall; external ‘ntdll.dll‘; //======================================== //函数:_GetTickCount64 //参数:无 //返回值:int64,操作系统启动以来时间,单位 毫秒 //环境: delphi 7 等32位 windows操作系统 //代用品: 64位等vista以后的操作系统有GetTickCount // function _GetTickCount64(): Int64; var st: SYSTEM_TIME_OF_DAY_INFORMATION; r: ULONG; ct: LARGE_INTEGER; quadpart:int64 absolute ct; quadpart2:int64 absolute st.BootTime; begin // NtQuerySystemInformation(SystemTimeOfDayInformation, @st, SizeOf(SYSTEM_TIME_OF_DAY_INFORMATION), @r); //查询系统时间,得到的单位是100钠秒 NtQuerySystemTime(ct); // //比如 100,000,000 除以 10 得到 微秒 再除以 1000 得到 毫秒 Result := (QuadPart - QuadPart2) div 10000; end; end.
一种GetTickCount64实现
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。