Crate winrt [] [src]

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();
    println!("Currently executed processes ({}):", unsafe { infos.get_size().unwrap() });
    for p in infos.into_iter() {
        let pid = unsafe { p.get_process_id().unwrap() };
        let exe = unsafe { 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
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.

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
RtAsyncOperation
RtClassInterface

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

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 Out 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)