Crates.io | com_ptr |
lib.rs | com_ptr |
version | 0.2.1 |
source | src |
created_at | 2019-06-08 15:33:30.211764 |
updated_at | 2021-02-25 14:15:51.477649 |
description | A smart pointer for Windows COM Interfaces |
homepage | |
repository | https://github.com/LNSEAB/com_ptr |
max_upload_size | |
id | 139830 |
size | 21,412 |
A smart pointer for Windows COM Interfaces
Creates a ComPtr from CreateDXGIFactory1
function.
use winapi::shared::dxgi::*;
use winapi::um::winnt::HRESULT;
use winapi::Interface;
use com_ptr::{ComPtr, hresult};
fn create_dxgi_factory<T: Interface>() -> Result<ComPtr<T>, HRESULT> {
ComPtr::new(|| {
let mut obj = std::ptr::null_mut();
let res = unsafe { CreateDXGIFactory1(&T::uuidof(), &mut obj) };
hresult(obj as *mut T, res)
})
}
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.