mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-03-27 09:49:49 +08:00
42 lines
995 B
C#
42 lines
995 B
C#
using MicaSetup.Natives;
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace MicaSetup.Helper;
|
|
|
|
public static class ExplorerHelper
|
|
{
|
|
public static void Refresh()
|
|
{
|
|
Shell32.SHChangeNotify(SHCNE.SHCNE_ASSOCCHANGED, SHCNF.SHCNF_FLUSH, 0, 0);
|
|
}
|
|
|
|
public static void RefreshDesktop()
|
|
{
|
|
Shell32.SHChangeNotify(SHCNE.SHCNE_ASSOCCHANGED, SHCNF.SHCNF_IDLIST, 0, 0);
|
|
}
|
|
|
|
public static void Refresh(string path = null!)
|
|
{
|
|
if (string.IsNullOrEmpty(path))
|
|
{
|
|
Refresh();
|
|
return;
|
|
}
|
|
|
|
nint strPtr = 0;
|
|
try
|
|
{
|
|
strPtr = Marshal.StringToHGlobalUni(path ?? Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
|
|
Shell32.SHChangeNotify(SHCNE.SHCNE_UPDATEDIR, SHCNF.SHCNF_PATHW, strPtr, 0);
|
|
}
|
|
finally
|
|
{
|
|
if (strPtr != 0)
|
|
{
|
|
Marshal.FreeHGlobal(strPtr);
|
|
}
|
|
}
|
|
}
|
|
}
|