#winapi #bindings #audio-devices #output #utilities #idiomatic-bindings

win32-util

High-level idiomatic bindings for a few parts of the Win32 API

4 releases

Uses new Rust 2024

0.2.1-alpha.1 Sep 22, 2025
0.2.0 Sep 21, 2025
0.1.0 Sep 21, 2025

#1405 in Database interfaces

Download history 260/week @ 2025-09-20 20/week @ 2025-09-27 3/week @ 2025-10-04

89 downloads per month

GPL-3.0-only

39KB
784 lines

win32-util

Wrappers for some assorted parts of the Win32 API that I find myself using, and wishing there were nicer-to-use bindings. Well, now there are. I think.

Usage

use windows::core::Result;
use win32_util::audio_outputs::{AudioDevice, EndpointRole, EndpointDataFlow, DeviceStateMask};
use win32_util::display_config::{self, set::Topology};

fn main() -> Result<()> {
    // Audio output devices
    let (flow, state) = (EndpointDataFlow::Render, DeviceStateMask::ACTIVE);
    for device in AudioDevice::enumerate(flow, state)? {
        let device = device?;
        println!("{}", device.long_name()?);
        if device.short_name()?.contains("Headphones") {
            device.set_as_default(EndpointRole::Multimedia)?;
        }
    }

    // Display config
    display_config::set::from_database(Topology::Extend)?;

    Ok(())
}

Dependencies

~115MB
~2M SLoC