如何用VBScript或PowerShell创建一个带有新图标的消息框?[已关闭]

问题描述 投票:0回答:1

我已经做了一段时间的VBScript和PowerShell消息框,但是,我想使用Windows 10这样的图标。

New icons

我唯一想做的就是把Windows 7的图标换成Windows 10的,因为它们更现代。

有什么方法可以改变这些图标吗?

windows powershell vbscript icons messagebox
1个回答
1
投票

这里有一个PowerShell的快速代码示例。

Add-Type -AssemblyName System.Windows.Forms | Out-Null
[System.Windows.Forms.Application]::EnableVisualStyles()
$btn = [System.Windows.Forms.MessageBoxButtons]::OK
$ico = [System.Windows.Forms.MessageBoxIcon]::Information
$Title = 'Welcome'
$Message = 'Hello world'
$Return = [System.Windows.Forms.MessageBox]::Show($Message, $Title, $btn, $ico)

输出

enter image description here

如果我找到了VBScript的解决方案,我会跟进。

希望这能帮到你。


0
投票

作为我评论的延伸,你的查询与这个SO线程非常相似。虽然不是针对PowerShell,但参考点是一样的。

如何加载与Windows 10上MessageBox使用的图标一样的图标?

这感觉像是user32.dll的bug,但Windows 8也有同样的问题,所以我猜微软并不在意。

你可以通过调用SHGetStockIconInfo来获得MessageBox使用的扁平图标。

SHSTOCKICONINFO sii;
    sii.cbSize = sizeof(sii);
    if (SUCCEEDED(SHGetStockIconInfo(SIID_INFO, SHGSI_ICON|SHGSI_LARGEICON, &sii)))
    {
        // Use sii.hIcon here...
        DestroyIcon(sii.hIcon);
    }

SHGetStockIconInfo是获得Vista及以后版本的Windows用户界面中使用的图标的记录方式。大多数图标来自imageres.dll,但你不应该认为这是事实......

© www.soinside.com 2019 - 2024. All rights reserved.