Windows Shell Functions

↘锁芯ラ 提交于 2019-12-24 06:24:05

问题


So I was following this tutorial:

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

when I cam across the sentence that casually says "Call the SHChangeNotify function". How do I do this? It is not recognized by powershell. Do I have to import some library in c++ and call it from a c++ program? I am on windows 10.


回答1:


I used the following to call a refresh on the desktop from powershell by using C# code:

  $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()

Hope this helps anyone still looking for an answer as the link provided by SimonS doesn't seem to work anymore.

p.s. this is where I got the idea from IDERA - Refreshing Icon Cache



来源:https://stackoverflow.com/questions/38107621/windows-shell-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!