Trait winsafe::prelude::kernel_Hglobal

source ·
pub trait kernel_Hglobal: Handle {
    // Provided methods
    fn GlobalAlloc(
        flags: Option<GMEM>,
        num_bytes: usize
    ) -> SysResult<GlobalFreeGuard> { ... }
    fn GlobalFlags(&self) -> SysResult<GMEM> { ... }
    fn GlobalLock(&self) -> SysResult<GlobalUnlockGuard<'_, Self>> { ... }
    fn GlobalReAlloc(
        &mut self,
        num_bytes: usize,
        flags: Option<GMEM>
    ) -> SysResult<()> { ... }
    fn GlobalSize(&self) -> SysResult<usize> { ... }
}
Available on crate feature kernel only.
Expand description

This trait is enabled with the kernel feature, and provides methods for HGLOBAL.

Prefer importing this trait through the prelude:

use winsafe::prelude::*;

Provided Methods§

source

fn GlobalAlloc( flags: Option<GMEM>, num_bytes: usize ) -> SysResult<GlobalFreeGuard>

GlobalAlloc function.

source

fn GlobalFlags(&self) -> SysResult<GMEM>

GlobalFlags function.

source

fn GlobalLock(&self) -> SysResult<GlobalUnlockGuard<'_, Self>>

GlobalLock function.

Calls GlobalSize to retrieve the size of the memory block.

§Examples
use winsafe::{self as w, prelude::*, co};

let hglobal = w::HGLOBAL::GlobalAlloc(
    Some(co::GMEM::FIXED | co::GMEM::ZEROINIT),
    120,
)?;

let mut block = hglobal.GlobalLock()?;

block.as_mut_slice()[0] = 40;

// GlobalUnlock() called automatically

// GlobalFree() called automatically
source

fn GlobalReAlloc( &mut self, num_bytes: usize, flags: Option<GMEM> ) -> SysResult<()>

GlobalReAlloc function.

Originally this method returns the handle to the reallocated memory object; here the original handle is automatically updated.

source

fn GlobalSize(&self) -> SysResult<usize>

GlobalSize function.

Object Safety§

This trait is not object safe.

Implementors§