[][src]Crate winrt

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

windows

Structs

BStr

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.

Char

Represents a single UTF-16 character. This is the standard character type in WinRT.

ComArray

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.

ComPtr

Smart pointer for Windows Runtime objects. This pointer automatically maintains the reference count of the underlying COM object.

FastHString

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.

Guid

Represents a GUID type in the Windows Runtime type system.

HString

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().

HStringArg

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.

HStringReference

A reference to either an HString, a FastHString, or a raw null-terminated UTF-16 buffer.

IActivationFactory

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.

IAgileObject

Interface that marks an object as agile. It inherits from IUnknown and does not have additional members.

IInspectable

The IInspectable interface is the base interface for all Windows Runtime classes.

IMemoryBufferByteAccess

Provides direct byte access to the memory buffer underlying an IMemoryBuffer.

IteratorAdaptor
RuntimeContext

Manages initialization and uninitialization of the Windows Runtime.

Enums

Error

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

Traits

ComIid

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.

ComInterface

Marker trait for all COM-compatible interfaces.

RtActivatable
RtAsyncAction

Extension for IAsyncAction with helper method.

RtAsyncOperation

Extension for IAsyncOperation with helper methods.

RtClassInterface

Marker trait for all interfaces that are not factories or statics.

RtDefaultConstructible

Enables easy access to a default constructor, using IActivationFactory under the hood.

RtInterface

Marker trait for all Windows Runtime interfaces. They must inherit from IInspectable.

RtNamedClass

This trait is implemented by all classes that have a name associated with them which can be used at runtime.

RtType

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.

RtValueType

Marker trait for all value types (primitive types, structs, enums) that can be used as generic parameters in Windows Runtime.

Type Definitions

HRESULT

Re-export from WinAPI crate

IRestrictedErrorInfo

Re-export from WinAPI crate

IUnknown

Re-export from WinAPI crate

Result

A specialized Result type for Windows Runtime method calls.

TrustLevel

Represents the trust level of an activatable class (re-export from WinAPI crate)