彩票网站开发制作需要什么,wordpress连接微博专业版v4.1,百度下载并安装最新版,学做静态网站文章目录 需求来源Windows查询Windows版本号方法1. 如何查看Windows版本号2. Windows开发如何通过代码查询Windows版本号(1) 使用C#代码#xff1a;(2) 使用VB.NET代码 3.通过注册表查看Windows版本信息 Flutter查询Windows版本号方法依赖库支持平台实现步骤1. 在pubspec.yaml… 文章目录 需求来源Windows查询Windows版本号方法1. 如何查看Windows版本号2. Windows开发如何通过代码查询Windows版本号(1) 使用C#代码(2) 使用VB.NET代码 3.通过注册表查看Windows版本信息 Flutter查询Windows版本号方法依赖库支持平台实现步骤1. 在pubspec.yaml中添加依赖2. 获取版本号 方法解释openPathgetValuegetValueAsStringgetValueAsIntcreateValuedeleteValuedeleteKeyrenameSubkey 注意事项拓展话题 需求来源
毛玻璃效果配置选项 WindowEffect.acrylicWindows 10 1803 及以上版本 WindowEffect.aeroWindows 10 1803以下版本 书接上回毛玻璃效果配置选项依据Windows的版本号而有所不同那么如何获取Windows的版本号了
Windows查询Windows版本号方法
1. 如何查看Windows版本号
要获取Windows版本号可以按照以下步骤进行操作 1打开运行对话框可以使用快捷键Win R。 2在运行对话框中输入winver然后点击确定按钮。 3弹出的窗口中会显示Windows的版本号和版本信息。
2. Windows开发如何通过代码查询Windows版本号
(1) 使用C#代码
using System;
using Microsoft.Win32;
class Program{static void Main(string[] args){string version string.Empty;using (RegistryKey key Registry.LocalMachine.OpenSubKey(SOFTWARE\Microsoft\Windows NT\CurrentVersion)){if (key ! null){version key.GetValue(CurrentVersion).ToString();}}Console.WriteLine(Windows版本号 version);}}(2) 使用VB.NET代码
Imports Microsoft.Win32
Module Module1Sub Main()Dim version As String String.EmptyUsing key As RegistryKey Registry.LocalMachine.OpenSubKey(SOFTWARE\Microsoft\Windows NT\CurrentVersion)If key IsNot Nothing Thenversion key.GetValue(CurrentVersion).ToString()End IfEnd UsingConsole.WriteLine(Windows版本号 version)End SubEnd Module通过C#和 .NET获取Windows版本的方法可以总结出2个关键点 1. 引入Win32依赖库 2. 读取注册表信息 3.通过注册表查看Windows版本信息
打开注册表编辑器输入计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion,就可以查看版本号信息
Flutter查询Windows版本号方法
Windows原生开发获取版本号的方法为Flutter提供了指导只要可以找到读写windows注册表就可以实现版本号的查询。目前flutter 已经提供了读写windows注册表的依赖库很方便我们实现相关功能.
依赖库
win32_registry
支持平台
Windows
实现步骤
1. 在pubspec.yaml中添加依赖
dependencies:...win32_registry: ^1.1.22. 获取版本号
import package:win32_registry/win32_registry.dart;int? getWindowBuildNumber() {const regCurrentVersionKey rSOFTWARE\Microsoft\Windows NT\CurrentVersion;final key Registry.openPath(RegistryHive.localMachine, path: regCurrentVersionKey);final mCurrentVersion key.getValueAsString(CurrentVersion);if (kDebugMode) {print(mCurrentVersion:$mCurrentVersion);}final mUBR key.getValueAsInt(UBR);if (kDebugMode) {print(mUBR:$mUBR);}return mUBR;
}打印值
flutter: mCurrentVersion:6.3
flutter: mUBR:1081方法解释
openPath
打开指定的注册表键
RegistryKey openPath(RegistryHive hive, {String path ,AccessRights desiredAccessRights AccessRights.readOnly,
})RegistryHive 注册表的入口 枚举值有localMachine(HKEY_LOCAL_MACHINE), currentUser(HKEY_CURRENT_USER), allUsers(HKEY_USERS), classesRoot(HKEY_CLASSES_ROOT), currentConfig(HKEY_CURRENT_CONFIG), performanceData(HKEY_PERFORMANCE_DATA); 除了performanceData以外其他的值与注册表一级目录一一对应
path注冊表的路径 desiredAccessRights 期望权限 readOnly(KEY_READ), writeOnly(KEY_WRITE), allAccess(KEY_ALL_ACCESS); createKey:创建一个新的注册表键 下面是通过注册表添加程序自动启的案例
Futurevoid updateRegistryTest() {const regCurrentVersionKey rSoftware\Microsoft\Windows\CurrentVersion\Run;final key Registry.openPath(RegistryHive.currentUser, path: regCurrentVersionKey,desiredAccessRights: AccessRights.writeOnly);key.createKey(WeChat);key.createValue(const RegistryValue(WeChat, RegistryValueType.string, D:\\Program Files (x86)\\Tencent\\WeChat\\WeChat.exe));key.close();
}创建结果如下
getValue
查询指定键的值
getValueAsString
查询字符串类型的指定键的值
getValueAsInt
查询Int类型的指定键的值
createValue
设置指定键的值
deleteValue
删除指定键的值
deleteKey
删除指定的注册表键
renameSubkey
更改指定注册表项的名称
注意事项
Unhandled Exception: Error 0x80070005: 拒绝访问
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Error 0x80070005: 拒绝访问。
#0 Registry.openPath (package:win32_registry/src/registry.dart:56:7)
#1 getWindowBuildNumber (package:window_example/util/window_util.dart:61:16)
#2 showAcrylic (package:window_example/util/window_util.dart:35:22)
#3 _MyHomePageState._init (package:window_example/main.dart:142:5)
asynchronous suspension出现该异常需要检查路径是否正确权限参数是否正确
拓展话题
Windows注册表介绍与操作