Brows.Win32.Interop.Composition 1.0.0

dotnet add package Brows.Win32.Interop.Composition --version 1.0.0
                    
NuGet\Install-Package Brows.Win32.Interop.Composition -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Brows.Win32.Interop.Composition" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Brows.Win32.Interop.Composition" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Brows.Win32.Interop.Composition" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Brows.Win32.Interop.Composition --version 1.0.0
                    
#r "nuget: Brows.Win32.Interop.Composition, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Brows.Win32.Interop.Composition@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Brows.Win32.Interop.Composition&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Brows.Win32.Interop.Composition&version=1.0.0
                    
Install as a Cake Tool

Brows.Win32.Interop.Composition

Composition exports for the Win32 file queries and Windows Shell actions in Brows.Win32.Interop. The IWin32InteropServices interface also creates batched Shell file operations.

Install

dotnet add package Brows.Win32.Interop.Composition

This package depends on Brows.Composition and Brows.Win32.Interop.Operations, which in turn depends on Brows.Win32.Interop. It targets .NET Framework 4.6.2 and 4.8, and .NET 8 and 10 on Windows. It calls Windows APIs and must run on Windows.

Use the exported services

Have the host's Brows.Composition setup supply IWin32InteropServices to the code that needs it:

using Brows.Win32;
using System.Threading;
using System.Threading.Tasks;

public sealed class DocumentActions(IWin32InteropServices services) {
    public async Task OpenShortcutAsync(string shortcutPath, CancellationToken cancellationToken) {
        var targetPath = await services.GetLinkPath(shortcutPath, cancellationToken);
        if (targetPath is not null) {
            await services.ExecuteDefault(targetPath, cancellationToken);
        }
    }

    public Task<bool> IsSameFileAsync(string path1, string path2, CancellationToken cancellationToken) {
        return services.PathsAreEquivalent(path1, path2, cancellationToken);
    }

    public Task<bool> DirectoryIsCaseSensitiveAsync(string directory, CancellationToken cancellationToken) {
        return services.PathIsCaseSensitive(directory, cancellationToken);
    }
}

PathsAreEquivalent compares the identity of existing files or directories, rather than their path text. PathIsCaseSensitive returns false when case-sensitive lookup is disabled or the query is unsupported; other query failures are reported by the returned task. ExecuteDefault runs a path's default Shell action, while its overload ExecuteDefault(file, with, cancellationToken) passes file to the specified executable. ExecuteProperties opens the Properties action. These Shell calls run on an STA worker, and their returned tasks report errors. Cancellation can stop queued work before the native call starts; it cannot interrupt a native call already running.

GetLinkPath returns a shortcut's target, or null if the path is not a shortcut or lookup fails. It does not check whether the target exists. Cancellation is propagated through the returned task.

Use FileOperation(directory) to create and execute a batch of Shell file operations. See Brows.Win32.Interop.Operations for batch configuration and progress.

File-operation owner window

To make Shell UI for file-operation batches owned by an application window, configure Win32InteropServicesVariable.OnGetOwnerWindow through the host's Brows.Composition variable configuration before the export creates its services:

var variable = new Win32InteropServicesVariable {
    OnGetOwnerWindow = () => ownerWindowHandle,
};

Supply variable to the host's configuration for this export. The callback applies to batches created by the export, runs on an STA worker during Operate, and must return promptly without synchronously waiting on a thread that could be waiting for the batch. Return IntPtr.Zero to run Shell UI without an owner window.

License

MIT.

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed.  net10.0-windows7.0 is compatible. 
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 32 10/5/2026