title: What is the appropriate way to access common ("stock") icons in Windows?
body: <p>Most operating systems tend to use a common set of &quot;stock&quot; icons for indicating &quot;warning&quot;, &quot;error&quot;, and other states. And most of us know that we should not <a href="https://devblogs.microsoft.com/oldnewthing/20200526-00/?p=103794" rel="nofollow noreferrer">grovel into undocumented resources</a> and use them in our application.</p>
  <p>However, in GTK, it is possible to retrieve these icons because the toolkit provides documented APIs to do so. In Windows, while it is <em>possible</em> to extract a limited set of icons from the appropriate DLLs, <em>this is undocumented and not guaranteed to work</em> in future versions of Windows. Icons provided by an API are a contract; icons stored in a DLL are an implementation detail.</p>
  <p><strong>Is there any Windows (or .NET 4) API function to retrieve a &quot;stock icon&quot;?</strong> I know that for file associations, one could grovel the registry to locate the DefaultIcon entry, but this wouldn't take into account custom icon handlers, and it is not a solution for other stock icons such as the ones used in warning or error message boxes.</p>
  <p>If there is no such functionality, <strong>what would be the most future-proof way</strong> to use these icons in my application? Or do I just have to do all the work myself and worry about Microsoft changing the implementation details in a future version of Windows?</p>