SHGetDesktopFolder function shell32

IShellFolder? SHGetDesktopFolder()

Retrieves the IShellFolder interface for the desktop folder, which is the root of the Shell's namespace.

Throws a WindowsException on failure.

To learn more, see learn.microsoft.com/windows/win32/api/shlobj_core/nf-shlobj_core-shgetdesktopfolder.

Implementation

IShellFolder? SHGetDesktopFolder() {
  final ppshf = adaptiveCalloc<VTablePointer>();
  final hr$ = HRESULT(_SHGetDesktopFolder(ppshf));
  if (hr$.isError) {
    free(ppshf);
    throw WindowsException(hr$);
  }
  final result$ = ppshf.value;
  free(ppshf);
  if (result$.isNull) return null;
  return .new(result$);
}