识别操作系统版本

CMake识别操作系统平台及Linux发行版本是ubuntu/centos 识别操作系统平台 以下代码可以识别 Windows、Linux、Macos三种类型的操作系统平台: IF (CMAKE_SYSTEM_NAME MATCHES "Linux") MESSAGE(STATUS "current platform: Linux ") ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows") MESSAGE(STATUS "current platform: Windows") ELSEIF (CMAKE_SYSTEM_N 阅读详情

07年7月份的时候在项目中做了一份操作系统识别的功能。当时是为了针对不同的操作系统实现不同的流程。今天,同样又有这个需求了。但由于,时隔一年有点想不起来了,于是又翻出来“陈年旧账”查找了一下。

实现功能后,觉得还是把一下常用的方法记录下来吧,方便自己的同时也能方便一下正在搜索该方法的朋友。

首先简单了解一下OSVERSIONINFO结构体。在这个结构体中包含了操作系统的主版本号、副版本号等信息。结构定义如下:

typedef struct _OSVERSIONINFO{  DWORDdwOSVersionInfoSize;

                                 DWORDdwMajorVersion;

                                 DWORDdwMinorVersion;

                                 DWORDdwBuildNumber;

                                 DWORDdwPlatformId;

                                 TCHARszCSDVersion[128];

                                } OSVERSIONINFO;

dwMajorVersion成员是表示操作系统的主版本号,请参考下表。 

Value

Meaning

4

Windows NT 4.0, Windows Me, Windows 98, Windows 95.

5

Windows Server 2003 R2, Windows Server 2003, Windows XP, Windows 2000.

6

Windows Vista, Windows Server 2008.

 

 

 

 

 

 

dwMinorVersion 成员是操作系统的副版本号,请参考下表。

Value

Meaning

0

Windows Vista, Windows Server 2008, Windows 2000, Windows NT 4.0, Windows 95.

1

Windows XP.

2

Windows Server 2003 R2, Windows Server 2003, Windows XP Professional x64 Edition.

10

Windows 98.

90

Windows Me.

dwPlatformId 成员是用来识别操作系统,请参考下表。

Value

Meaning

VER_PLATFORM_WIN32_NT2

Windows Vista, Windows Server 2008, Windows Server 2003, Windows XP, Windows 2000, Windows NT.

VER_PLATFORM_WIN32_WINDOWS1

Windows Me, Windows 98, Windows 95.

 

使用上面介绍的这三个成员就可以完成操作系统识别的工作了。

代码:

    OSVERSIONINFO versionInfo;

::ZeroMemory(&versionInfo, sizeof(versionInfo));

versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);

::GetVersionEx(&versionInfo);

使用GetVersionEx()函数来填充这个结构体,这样我们关心的信息就都找到了,剩下的事情只是做简单的判断。

例如:如何判断是Windows XP 系统

BOOL IsWinXp()

{

if(m_dwPlatformId == VER_PLATFORM_WIN32_NT && (m_dwMajorVersion == 5 && m_dwMinorVersion >= 1))

{

return TRUE;

}

return FALSE;

}

本文只是很肤浅的引子,具体的内容请参看MSDN

VC下判断系统版本代码 VC 判断系统版本 代码 Win32s, WinNT3, Win95, Win98, WinME, WinNT4, Win2000, WinXP, VISTA, WIN7 立即下载

相关推荐

安卓模拟器绕过检测全解析:雷电、MuMu、蓝叠、逍遥、夜神与WSA完整指南

随着手机游戏和应用的普及,越来越多的用户选择在PC上通过模拟器来运行安卓应用。然而,许多应用和游戏为了防止作弊或出于安全考虑,会检测是否运行在模拟器环境中。本文将详细介绍各大主流模拟器的检测绕过方法,帮助用户在电脑上流畅体验各类安卓应用。1. 获取模拟器系统镜像2. 使用ROM厨房工具修改系统文件3. 替换模拟器的系统镜像雷电模拟器:适合游戏,推荐使用MAGISK + EdXposed方案MuMu模拟器:适合中度游戏,推荐太极框架蓝叠模拟器:适合国际应用,推荐MAGISK方案逍遥模拟器。

专注技术分享 3万+

RtlGetVersion获取操作系统版本

#include #include //操作系统版本 #define WINXP 51 #define WINXP2600 512600 #define WIN7 61 #define WIN77600 617600 #define WIN77601 617601 #define WIN8 62 #define WIN89200 62920

125096 8181

《解锁GCC版本选择的奥秘:从入门到精通》

GCC 版本的选择是一项复杂而关键的决策,犹如一场精心策划的战略布局,贯穿于软件开发的整个生命周期。从项目需求与兼容性的深度考量,到性能与稳定性的权衡抉择,再到硬件与系统适配的精准对接,每一个环节都紧密相连,相互影响。在游戏开发行业,对性能的极致追求促使开发者青睐较新的 GCC 版本,以实现更流畅的游戏体验和更震撼的视觉效果;科学计算领域则依赖于 GCC 版本对复杂数学运算的高效优化,以应对大规模数据处理的挑战;嵌入式开发行业因硬件资源的限制和对稳定性的严苛要求,通常选择经过长期验证的稳定版本;

zheng_ruiguo的专栏 1422

判断windows 版本

Windows 2000: dwMajorVersion = 5 dwMinorVersion = 0 Windows XP: dwMajorVersion = 5 dwMinorVersion = 1 Windows Vista: dwMajorVersion = 6 API函数:GetVersionEx() void __fastcall TForm1

coderlife的专栏 1781

本地如何安装midscene.js运行环境

手把手教你本地安装midscene.js运行环境

实践助梦想成长 2610

pcle接口详解&用途说明

它原来的名称为“3GIO”,由英特尔在2001年提出。pcel x16插槽 用途用于显卡、RAID阵列卡,向下兼容PCIE x1/x4/x8/x16。(PCIE x16插槽长89mm,有164根针脚,靠主板外侧端有一卡口,将16x分为前后两组,短插槽有22根针脚,主要用于供电,长插槽142根,主要用于数据传输,具有16通道所带来的高带宽)PCI-E x8插槽插槽用途:全长56mm,有98根针脚,与PCI-E x16比较,主要是数据针脚减少至76根,短的供电针脚仍然是22针脚。

qq_43289307的博客 1万+

获取系统版本号

获取系统版本号

weixin_37724132的博客 749

别再只改config了!YOLO/RT-DETR多通道输入实战:数据集结构、多卡训练与参数优先级避坑指南

本文详细解析了YOLO/RT-DETR模型在多通道输入(如8通道多光谱图像)中的实战应用,涵盖数据集结构优化、数据加载器改造、模型参数调优及多卡训练配置。针对常见的多通道输入报错问题,提供了系统的解决方案和性能优化技巧,帮助开发者高效实现非标准数据格式的适配与训练。

weixin_30955617的博客 397

获取系统版本-OSVERSIONINFOEX结构解析

现如今系统版本主要有: WindowsNT Windows2000 WindowsXP Windows2003 WindowsVista Windows7 Windows10等 获取系统版本就必须说说以下这个函数: BOOL GetVersionEx(POSVERSIONINFOEX pVersionInformation); 这个函数要求我们在自己的应用程序中分配一个OSVERSIONINFOE...

weixin_45239587的博客 2765

ArcGIS中地理坐标系与投影坐标系以及投影转换

简单介绍arcgis软件中坐标系定义、设置和常见问题。

weixin_41399650的博客 8万+

UE5导入MetaHuman虚拟头像后,连接live link face,面部表情捕捉出错修正

UE5 利用live link face 驱动meta human面部表情捕捉

m0_53122690的博客 6596

nmap操作系统版本的识别

注意:安全溢出漏洞,每个版本的漏洞位置不一样。如果溢出错误会导致系统崩溃掉,主机就不会工作了 一、操作参数 1.-O: 启动操作系统识别 2.--osscan-limit:限定只识别有端口开放的主机;提高-O和-A参数时的扫描速度。 3.--osscan-guest<OS>:给N...

chibo8600的博客 9419

Python 爬虫项目:爬取百度贴吧帖子,保存标题与评论内容

在 Python 爬虫技术的学习与实战体系中,贴吧类动态内容爬取是典型的入门进阶案例,百度贴吧作为国内主流的社区论坛平台,其页面结构规范、数据载体清晰,非常适合用于巩固爬虫核心技术栈。本次实战项目基于requests请求库与解析库实现完整的爬取流程,从网页请求、数据解析、内容提取到本地持久化存储全链路落地,既能掌握基础爬虫的核心逻辑,也能理解网页结构化数据解析的通用思路,同时规避爬虫常见的反爬基础策略,具备极高的实战参考价值。本文核心价值。

2503_91057718的博客 2544

如何识别操作系统版本

07年7月份的时候在项目中做了一份操作系统识别的功能。当时是为了针对不同的操作系统实现不同的流程。今天,同样又有这个需求了。但由于,时隔一年有点想不起来了,于是又翻出来“陈年旧账”查找了一下。实现功能后,觉得还是把一下常用的方法记录下来吧,方便自己的同时也能方便一下正在搜索该方法的朋友。首先简单了解一下OSVERSIONINFO结构体。在这个结构体中包含了操作系统的主版本号、副版本号等信息

大白(奋斗)的专栏 2964

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

js识别操作系统以及浏览器版本

<script type="text/javascript"> var getOSAndBrowser = function () { var os = navigator.platform; var userAgent = navigator.userAgent; var info = ""; ...

weixin_30474613的博客 152

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

基于RDP协议识别主机操作系统版本与用户名

网络安全攻防技术必将愈发体现出人工智能及机器学习介入的影响,未来的网络安全将会越来越多地出现AI vs AI的攻防局面,墨云将一直专注人工智能在攻防安全领域的应用研究,打造智能化产品体系,为用户提供全方位的信息安全服务。...

Moyun_vackbot的博客 1521

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

渗透测试技术----服务扫描(一)--Banner、服务版本扫描、操作系统识别

一、服务扫描 在进行渗透测试的时候,首先要收集信息,可以进行端口扫描,但是不能单纯的以端口来辨别服务,因为管理员为了安全起见,会将一些服务的端口进行修改,这样可以提高安全性,因此有必要对服务进行扫描。很多网络服务是漏洞频发的高危对象,对网络上的特定服务进行扫描,往往能让我们少走弯路,增加渗透成功的几率。因此很多渗透测试人员在确定了开放端口后,通常会对相应端口上所运行服务的信息进行更深入的挖掘,通常...

wwl012345的博客 1万+

浏览器识别(包括呈现引擎,浏览器版本,操作系统,移动设备)

一般应优先考虑能力检测,其次是怪癖检测,最后才是浏览器识别(因为基于用户代理检测,对用户代理字符串有很强的依赖性,而用户代理字符串由于其历史原因具有欺骗性)

u014617412的专栏 714

User Agent(识别客户使用的操作系统及版本)

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33948416的博客 1014

linux如何查看puma版本,js如何判断操作系统版本

var osData = [{ name: 'Windows 2000', group: 'windows_server', identifier: 'Windows NT 5.0', version: '5.0' },{ name: 'Windows XP', group: 'windows', identifier: 'Windows NT 5.1', version: '5.1' },{ n...

weixin_39561168的博客 257

trivy是怎么识别镜像操作系统及版本的

主要看github.com/aquasecurity/fanal/analyzer/os这个包下的代码。

K0000000r的专栏 189

windows系统版本判断

//判断当前操作系统版本 void JudgeOperatingSystem(string &OperatingSystem) { SYSTEM_INFO info; GetSystemInfo(&info); OSVERSIONINFOEX osvi; ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersion

RyanLunar 1007

获取操作系统版本(Windows)

The following example uses the GetVersionEx, GetSystemMetrics, GetProductInfo, and GetNativeSystemInfo functions to determine the version information of the currently running operating system. If

Jacholy的专栏 872
上一篇: Linux 下socket超时(connect超时/recv超时)
下一篇: java 快速开发框架
zljjava
博客等级 码龄15年 155粉丝 15原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值