内核里获得系统版本,与系统滴答时间

获得系统版本号。内核编程难免使用硬编码,以及使用一些高版本系统才出现的函数。为了使得驱动能在低版本的系统上正常运行,就需要根据不同系统做不同处理了。

VOID GetVersion()
{
ULONG NtBuildNumber;
RTL_OSVERSIONINFOW osi;
osi.dwOSVersionInfoSize=sizeof(RTL_OSVERSIONINFOW);
RtlFillMemory(&osi,sizeof(RTL_OSVERSIONINFOW),0);
RtlGetVersion(&osi);
NtBuildNumber=osi.dwBuildNumber;
DbgPrint("NtBuildNumber: %ld\n",NtBuildNumber);
return NtBuildNumber;
}

获得系统时间。在内核里获得系统时间的是标准时间(GMT+0),转换成本地时间还需要进行转换。此功能在发布测试版软件的时候特别有用,限制人们只能在指定时间之前使用。

VOID MyGetCurrentTime()
{
 LARGE_INTEGER CurrentTime;
 LARGE_INTEGER LocalTime;
 TIME_FIELDS TimeFiled;
 // 这里得到的其实是格林威治时间
 KeQuerySystemTime(&CurrentTime);
 // 转换成本地时间
 ExSystemTimeToLocalTime(&CurrentTime, &LocalTime);
 // 把时间转换为容易理解的形式
 RtlTimeToTimeFields(&LocalTime, &TimeFiled);
 DbgPrint("[TimeTest] NowTime : %4d-%2d-%2d %2d:%2d:%2d",
TimeFiled.Year, TimeFiled.Month, TimeFiled.Day,
TimeFiled.Hour, TimeFiled.Minute, TimeFiled.Second);
}

原文地址:https://www.cnblogs.com/csnd/p/11719007.html

时间: 2024-08-05 07:32:51

内核里获得系统版本,与系统滴答时间的相关文章

CentOS查看内核版本、系统版本、系统位数

CentOS查看内核版本.系统版本.系统位数 查看Linux内核版本 [[email protected] ~]# cat /proc/version    Linux version 2.6.32-358.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Fri Feb 22 00:31:26 UTC 2013     [[email protected] ~]

STM32系统时钟配置,滴答定时器配置相关

以后实在找不到问题出现在哪里,注意还有这么个地方需要留意: 今天在调试滴答定时器,找半天找不到延时为什么不准确,原来以前的代码中,"SYSCLK_FREQ_72MHz"被写成了64MHz了,把这里重新改为72MHz就可以了,走过的路过的,希望这个提醒可以对大家有所帮助,不过大家还是要看实际情况. 原文地址:https://www.cnblogs.com/data-base-of-ssy/p/9513371.html

linux查看系统版本和系统位数 (转)

1. uname -ayou will view kernel name.network node hostname.kernel release.kernel version.machine hardware name.processor type .hardware platform.operating system 2. cat /proc/version his file will not show you the name of the actual OS release, but w

linux查看系统版本和系统位数

1. uname -a you will view  kernel name.network node hostname.kernel release.kernel version.machine hardware name.processor type .hardware platform.operating system 2. cat /proc/version his file will not show you the name of the actual OS release, but

查看Linux系统版本和内核信息

Linux 查看Linux系统版本信息 1. 查看内核版本 1) 方法一:登录到linux执行cat /proc/version [[email protected]_32bit_ip12 ~]$ cat /proc/version  Linux version 2.6.18-194.el5 ([email protected]) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Fri Apr 2 14:58:35 EDT 2010 

提取操作系统的基本信息(内核、系统版本、网络地址等)

功能一:能够提取操作系统的基本信息(内核.系统版本.网络地址等) ############################################################################# #File Name:System_monitor.sh #Author:Ivan ############################################################################# #!/bin/bash #把之前屏幕上

Ubuntu 中查看内核版本和系统版本的三个命令

一.查看内核版本:cat /proc/version 二.查看内核版本:uname -a 三.查看系统版本:lsb_release -a

Ubuntu12.04 查看内核版本以及系统位数

查看内核的几种方法: 1. uname -a   #显示详细的内核信息, Linux localhost.localdomain 2.6.18-92.1.6.el5xen #1 SMP Wed Jun 25 12:56:52 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux 2. cat /etc/issue   #显示版本类型 Scientific Linux SL release 5.2 (Boron)Kernel \r on an \m 3. cat /pro

CentOS(RHEL)内核版本与系统版本对应关系

通过本文你可以获取如下信息: CentOS/RHEL 内核源码包下载地址. CentOS/RHEL 内核版本和系统版本对应关系. CentOS/RHEL 各个系统版本发布时间. CenOS 各个版本源码包及RPM包下载地址. 以下信息全部来自官方:http://vault.centos.org/ Name Last modified Size Description 对应内核源码包 5.0/ 11-Apr-2007 18:53 - kernel-2.6.18-8.el5.src.rpm 5.1/