Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
GLSL
Go
Haskell
HLSL
Hook
Hylo
IL
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Nim
Objective-C
Objective-C++
OCaml
Odin
OpenCL C
Pascal
Pony
Python
Racket
Ruby
Rust
Snowball
Scala
Slang
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
TypeScript Native
V
Vala
Visual Basic
Vyper
WASM
Zig
Javascript
GIMPLE
Ygen
csharp source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
.NET (main)
.NET (main) CoreCLR
.NET (main) Crossgen2
.NET (main) ILDasm
.NET (main) ILSpy
.NET (main) Mono
.NET (main) NativeAOT
.NET 6.0 CoreCLR
.NET 6.0 Crossgen2
.NET 6.0 ILDasm
.NET 6.0 ILSpy
.NET 6.0 Mono
.NET 6.0.110
.NET 6.0.113
.NET 6.0.116
.NET 7.0 CoreCLR
.NET 7.0 Crossgen2
.NET 7.0 ILDasm
.NET 7.0 ILSpy
.NET 7.0 Mono
.NET 7.0.100
.NET 7.0.102
.NET 7.0.105
.NET 8.0 CoreCLR
.NET 8.0 Crossgen2
.NET 8.0 ILDasm
.NET 8.0 ILSpy
.NET 8.0 Mono
.NET 9.0 CoreCLR
.NET 9.0 Crossgen2
.NET 9.0 ILDasm
.NET 9.0 ILSpy
.NET 9.0 Mono
Options
Source code
// Framework: .NET Framework // Technology Stack: WinAPI using System; using System.Runtime.InteropServices; namespace WinAPI { public static class UpdateEnvExplorer { private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff); private const int WM_SETTINGCHANGE = 0x1a; private const int SMTO_ABORTIFHUNG = 0x0002; [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] static extern bool SendNotifyMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] private static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, UIntPtr wParam, IntPtr lParam, int fuFlags, int uTimeout, IntPtr lpdwResult); [DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)] private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2); public static void Refresh() { // Update desktop icons SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero); // Update environment variables SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, UIntPtr.Zero, IntPtr.Zero, SMTO_ABORTIFHUNG, 100, IntPtr.Zero); // Update taskbar SendNotifyMessage(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "TraySettings"); } public static void Main() { // Restart Start menu // Перезапустить меню "Пуск" System.Diagnostics.Process.Start("taskkill", "/F /IM StartMenuExperienceHost.exe"); // Refresh desktop icons, environment variables and taskbar without restarting File Explorer // Обновить иконки рабочего стола, переменные среды и панель задач без перезапуска "Проводника" // Call the Refresh method to perform the updates WinAPI.UpdateEnvExplorer.Refresh(); } } }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
CE on Bluesky
About the author
Statistics
Changelog
Version tree