Crate winrt

source ·
Expand description

Using Windows Runtime APIs from Rust.

Example

extern crate winrt;

use winrt::*; // import various helper types
use winrt::windows::system::diagnostics::*; // import namespace Windows.System.Diagnostics

fn main() {
    let rt = RuntimeContext::init(); // initialize the Windows Runtime
    let infos = ProcessDiagnosticInfo::get_for_processes().unwrap().unwrap();
    println!("Currently executed processes ({}):", infos.get_size().unwrap());
    for p in &infos {
        let p = p.unwrap();
        let pid = p.get_process_id().unwrap();
        let exe = p.get_executable_file_name().unwrap();
        println!("[{}] {}", pid, exe);
    }
}

Modules

Structs

A wrapper around BSTR, a string type used by classic COM. This is usually not needed when working with WinRT, but can be helpful when interacting with other APIs.
Represents a single UTF-16 character. This is the standard character type in WinRT.
Owned array type that is used as return type when WinRT methods return arrays. It wraps a block of memory that has been allocated by WinRT and will be deallocated using CoTaskMemFree on drop.
Smart pointer for Windows Runtime objects. This pointer automatically maintains the reference count of the underlying COM object.
A string type that should be used to create strings that can be passed to Windows Runtime functions. Creating a new FastHString is faster than creating an instance of HString because it eliminates an additional allocation. Furthermore, obtaining a HStringArg from a FastHString is basically free, which is not the case for HString.
Represents a GUID type in the Windows Runtime type system.
A wrapper over an HSTRING whose memory is managed by the Windows Runtime. This is what you get as return values when calling WinRT methods that return strings. Note that dereferencing to &HStringArg is not implemented for this, because the containing HSTRING might be null (empty string), and null references are not allowed. In order to obtain an &HStringArg from an HString, first create an HStringReference using make_reference().
References of this type are passed to WinRT functions. You can not create a value of this type, only references can exist and are obtained via (automatic) dereferencing of FastHString or HStringReference.
A reference to either an HString, a FastHString, or a raw null-terminated UTF-16 buffer.
Enables classes to be activated using a default constructor. This interface should not be used directly, but the new() method of the RtDefaultConstructible trait should be used instead.
Interface that marks an object as agile. It inherits from IUnknown and does not have additional members.
The IInspectable interface is the base interface for all Windows Runtime classes.
Provides direct byte access to the memory buffer underlying an IMemoryBuffer.
Manages initialization and uninitialization of the Windows Runtime.

Enums

Represents an error as a result of a Windows Runtime method call.

Traits

Provides a way to get the IID for a COM/WinRT interface. This should be implemented for all interfaces, except parameterized ones, because IIDs of parameterized interfaces depend on concrete instantiations of the parameter types.
Marker trait for all COM-compatible interfaces.
Extension for IAsyncAction with helper method.
Extension for IAsyncOperation with helper methods.
Marker trait for all interfaces that are not factories or statics.
Enables easy access to a default constructor, using IActivationFactory under the hood.
Marker trait for all Windows Runtime interfaces. They must inherit from IInspectable.
This trait is implemented by all classes that have a name associated with them which can be used at runtime.
This is a trait implemented by all types that can be used as generic parameters of parameterized interfaces. Abi and OutNonNull must be binary compatible (i.e. wrap must basically be the same as transmute) in order to work in ComArray.
Marker trait for all value types (primitive types, structs, enums) that can be used as generic parameters in Windows Runtime.

Type Definitions

Re-export from WinAPI crate
Re-export from WinAPI crate
Re-export from WinAPI crate
A specialized Result type for Windows Runtime method calls.
Represents the trust level of an activatable class (re-export from WinAPI crate)