gpt4 book ai didi

powershell - 检查注册表项 (reg_binary) 的第 13 位(影子设置)?

转载 作者:行者123 更新时间:2023-12-03 09:40:48 26 4
gpt4 key购买 nike

使用以下 PowerShell 代码:

$RegConnect = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]"CurrentUser", "$env:COMPUTERNAME")
$RegCursors = $RegConnect.OpenSubKey("Control Panel\Desktop", $true)
$myVal = $RegCursors.GetValue("UserPreferencesMask")
write-output $myVal
$RegCursors.Close()
$RegConnect.Close()

它返回:

190
30
7
128
18
1
0
0

来自MS helpUserPreferencesMask 上,我要找的是第 13 位,光标阴影

13 Cursor shadow -- 1 Default

Cursor shadow is enabled. This effect only appears if the system has a color depth of more than 256 colors.

如何从中提取当前鼠标阴影的 bool 值?


这是开启和关闭状态下的值。

on = "UserPreferencesMask"=hex:be,3e,07,80,12,01,00,00

off = "UserPreferencesMask"=hex:be,1e,07,80,12,01,00,00

最佳答案

看起来您正在向第二个字节添加 32 或 0x20 以将其打开:

$myval[1] += 32 # on
$myval[1] -= 32 # off

按位,“或”设置,“与”用“位补(非)”取消设置。

0x1e -bor 0x20 # on
62

0x3e -band -bnot 0x20 # off
30

也许您可以为所有设置创建一个标志枚举,但您必须将字节数组转换为一个大的 int。

编辑:哦,如果你只是想检查一下是否设置了:

$shadowbit = 0x20
if (0x3e -band $shadowbit ) { 'yep' } else { 'nope' } # 32
yep

if (0x1e -band $shadowbit ) { 'yep' } else { 'nope' } # 0
nope

另见 How do you set, clear, and toggle a single bit?

编辑:

我有点过分了。准备就绪:

[Flags()] enum UserPreferencesMask {
ActiveWindowTracking = 0x1
MenuAnimation = 0x2
ComboBoxAnimation = 0x4
ListBoxSmoothScrolling = 0x8
GradientCaptions = 0x10
KeybordCues = 0x20
ActiveWindowTrackingZOrder = 0x40
HotTracking = 0x80
Reserved8 = 0x100
MenuFade = 0x200
SelectionFade = 0x400
ToolTipAnimation = 0x800
ToolTipFade = 0x1000
CursorShadow = 0x2000 # 13
Reserved14 = 0x4000
Reserved15 = 0x8000
Reserved16 = 0x10000
Reserved17 = 0x20000
Reserved18 = 0x40000
Reserved19 = 0x80000
Reserved20 = 0x100000
Reserved21 = 0x200000
Reserved22 = 0x400000
Reserved23 = 0x800000
Reserved24 = 0x1000000
Reserved25 = 0x2000000
Reserved26 = 0x4000000
Reserved27 = 0x8000000
Reserved28 = 0x10000000
Reserved29 = 0x20000000
Reserved30 = 0x40000000
UIEffects = 0x80000000 # 31
}

你可以这样做:

$myVal = get-itemproperty 'HKCU:\Control Panel\Desktop' UserPreferencesMask |
% UserPreferencesMask
$b = [bitconverter]::ToInt32($myVal,0)

'0x{0:x}' -f $b
0x80073e9e

[UserPreferencesMask]$b
MenuAnimation, ComboBoxAnimation, ListBoxSmoothScrolling,
GradientCaptions, HotTracking, MenuFade, SelectionFade,
ToolTipAnimation, ToolTipFade, CursorShadow, Reserved16, Reserved17,
Reserved18, UIEffects

[UserPreferencesMask]$b -band 'CursorShadow'
CursorShadow

if ([UserPreferencesMask]$b -band 'CursorShadow') { 'yes' }
yes

请注意,3 个未记录的保留位已在我的 Windows 10 中使用。这是在控制面板的“性能选项”(高级系统)下选中“在鼠标指针下显示阴影”

或者,在没有枚举的情况下变得简单:

$b = [bitconverter]::ToInt32($myVal,0)  # 4 bytes from reg_binary to int
if ($b -band [math]::pow(2,13)) { 'cursor shadow' }

我注意到该注册表项实际上是 8 个字节长,但引入所有 8 个字节并不会改变答案,即使其中一些额外位是在 Windows 10 中设置的。

关于powershell - 检查注册表项 (reg_binary) 的第 13 位(影子设置)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59793453/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com