gpt4 book ai didi

windows-10 - 从 PowerShell 调用 Windows Shell 函数?

转载 作者:行者123 更新时间:2023-12-04 00:27:43 25 4
gpt4 key购买 nike

所以我正在学习本教程:

https://msdn.microsoft.com/en-us/library/windows/desktop/hh127427(v=vs.85).aspx

当我偶然看到“调用 SHChangeNotify 函数”这句话时。我该怎么做呢?它不被 powershell 识别。我是否必须在 C++ 中导入一些库并从 C++ 程序中调用它?我在 Windows 10 上。

最佳答案

我使用以下代码通过 C# 代码从 powershell 调用桌面刷新:

  $code = @'
[System.Runtime.InteropServices.DllImport("Shell32.dll")]
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);

public static void Refresh() {
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
}
'@

Add-Type -MemberDefinition $code -Namespace WinAPI -Name Explorer
[WinAPI.Explorer]::Refresh()

希望这对仍在寻找答案的任何人有所帮助,因为 SimonS 提供的链接似乎不再有效。

附注这是我从 IDERA - Refreshing Icon Cache 得到灵感的地方

关于windows-10 - 从 PowerShell 调用 Windows Shell 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38107621/

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