Struct winsafe::HINSTANCE[][src]

#[repr(C)]
pub struct HINSTANCE { /* fields omitted */ }
Expand description

Handle to an instance, same as HMODULE.

Implementations

The null, invalid handle.

This constant is common to all handle types.

Creates a new handle instance by wrapping a pointer.

This method is common to all handle types.

Consumes the handle returning the underlying raw pointer.

This method is common to all handle types.

Tells if the handle is invalid (null).

This method is common to all handle types.

Consumes the handle into an option, which is None if the handle pointer is null.

This method is common to all handle types.

FindResource method.

For an example, see HINSTANCE::LockResource.

FindResourceEx method.

For an example, see HINSTANCE::LockResource.

FreeLibrary method.

GetClassInfoEx method.

Examples

Retrieving information of a window class created in our application:

use winsafe::{HINSTANCE, WNDCLASSEX};

let mut wcx = WNDCLASSEX::default();
HINSTANCE::GetModuleHandle(None)?
    .GetClassInfoEx("SOME_CLASS_NAME", &mut wcx)?;

GetModuleFileName method.

Examples

Retrieving the full path of currently running .exe file:

use winsafe::HINSTANCE;

let exe_name = HINSTANCE::NULL.GetModuleFileName()?;

println!("EXE: {}", exe_name);

GetModuleHandle static method.

Examples

Retrieving current module instance:

use winsafe::HINSTANCE;

let hinstance = HINSTANCE::GetModuleHandle(None)?;

LoadCursor method.

Examples

Loading a system cursor:

use winsafe::{co, HINSTANCE, IdIdc};

let sys_cursor = HINSTANCE::default()
    .LoadCursor(IdIdc::Idc(co::IDC::ARROW))?;

LoadIcon method.

Examples

Loading a system icon:

use winsafe::{co, IdIdi, HINSTANCE};

let sys_icon = HINSTANCE::default()
    .LoadIcon(IdIdi::Idi(co::IDI::INFORMATION))?;

LoadImage method for HBITMAP.

LoadImage method for HCURSOR.

LoadImage method for HICON.

LoadLibrary static method.

Note: Must be paired with an HINSTANCE::FreeLibrary call.

LoadMenu method.

LoadResource method.

For an example, see HINSTANCE::LockResource.

LoadString method.

LockResource method.

This method should belong to HRSRCMEM, but in order to make it safe, we automatically call HINSTANCE::SizeofResource, so it’s implemented here.

Examples

The Updating Resources example:

use winsafe::{HINSTANCE, HUPDATERSRC, LANGID};
use winsafe::{co, IdStr, RtStr};

const IDD_HAND_ABOUTBOX: u16 = 103;
const IDD_FOOT_ABOUTBOX: u16 = 110;

let hExe = HINSTANCE::LoadLibrary("hand.exe")?;

let hRes = hExe.FindResource(
    IdStr::Id(IDD_HAND_ABOUTBOX),
    RtStr::Rt(co::RT::DIALOG),
)?;

let hResLoad = hExe.LoadResource(hRes)?;
let lpResLock = hExe.LockResource(hRes, hResLoad)?;
let hUpdateRes = HUPDATERSRC::BeginUpdateResource("foot.exe", false)?;

hUpdateRes.UpdateResource(
    RtStr::Rt(co::RT::DIALOG),
    IdStr::Id(IDD_FOOT_ABOUTBOX),
    LANGID::new(co::LANG::NEUTRAL, co::SUBLANG::NEUTRAL),
    lpResLock,
)?;

hUpdateRes.EndUpdateResource(false)?;

hExe.FreeLibrary()?;

SizeofResource method.

For an example, see HINSTANCE::LockResource.

Trait Implementations

Formats the value using the given formatter.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter.

Formats the value using the given formatter.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Formats the value using the given formatter.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.