检测系统架构
To detect system architecture
我正在尝试编写一个非常简单的代码来检测笔记本电脑的架构。下面是代码。我的笔记本电脑是 64 位的,但它也会显示 32 位的消息框。我还缺少其他代码吗?
#Load assembly
add-type -assemblyname system.windows.forms
#Assign messagebox to variable
$message1 = [System.Windows.Forms.MessageBox]::Show("This is a 64 bit version" , "Status")
$message2 = [System.Windows.Forms.MessageBox]::Show("This is a 32 bit version" , "Status")
#Display message based on the architecture
if ([System.Environment]::Is64BitProcess) {
echo $message1
} else {
echo $message2
}
您的消息框在变量声明时是运行,您可以通过运行 $x = [System.Windows.Forms.MessageBox]::Show("This is a 64 bit version" , "Status")
语句来确认 only.show 方法显示消息框并存储变量中消息的响应(在本例中为"ok"),试试这个:
#Load assembly
add-type -assemblyname system.windows.forms
#Display message based on the architecture
if ([System.Environment]::Is64BitProcess) {
[System.Windows.Forms.MessageBox]::Show("This is a 64 bit version" , "Status")
} else {
[System.Windows.Forms.MessageBox]::Show("This is a 32 bit version" , "Status")
}
我正在尝试编写一个非常简单的代码来检测笔记本电脑的架构。下面是代码。我的笔记本电脑是 64 位的,但它也会显示 32 位的消息框。我还缺少其他代码吗?
#Load assembly
add-type -assemblyname system.windows.forms
#Assign messagebox to variable
$message1 = [System.Windows.Forms.MessageBox]::Show("This is a 64 bit version" , "Status")
$message2 = [System.Windows.Forms.MessageBox]::Show("This is a 32 bit version" , "Status")
#Display message based on the architecture
if ([System.Environment]::Is64BitProcess) {
echo $message1
} else {
echo $message2
}
您的消息框在变量声明时是运行,您可以通过运行 $x = [System.Windows.Forms.MessageBox]::Show("This is a 64 bit version" , "Status")
语句来确认 only.show 方法显示消息框并存储变量中消息的响应(在本例中为"ok"),试试这个:
#Load assembly
add-type -assemblyname system.windows.forms
#Display message based on the architecture
if ([System.Environment]::Is64BitProcess) {
[System.Windows.Forms.MessageBox]::Show("This is a 64 bit version" , "Status")
} else {
[System.Windows.Forms.MessageBox]::Show("This is a 32 bit version" , "Status")
}