ホーム › UI.Controls › LoadIconMetric
LoadIconMetric
関数システムメトリックに合わせたサイズでアイコンを読み込む。
シグネチャ
// COMCTL32.dll
#include <windows.h>
HRESULT LoadIconMetric(
HINSTANCE hinst, // optional
LPCWSTR pszName,
_LI_METRIC lims,
HICON* phico
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hinst | HINSTANCE | inoptional |
| pszName | LPCWSTR | in |
| lims | _LI_METRIC | in |
| phico | HICON* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// COMCTL32.dll
#include <windows.h>
HRESULT LoadIconMetric(
HINSTANCE hinst, // optional
LPCWSTR pszName,
_LI_METRIC lims,
HICON* phico
);[DllImport("COMCTL32.dll", ExactSpelling = true)]
static extern int LoadIconMetric(
IntPtr hinst, // HINSTANCE optional
[MarshalAs(UnmanagedType.LPWStr)] string pszName, // LPCWSTR
int lims, // _LI_METRIC
IntPtr phico // HICON* out
);<DllImport("COMCTL32.dll", ExactSpelling:=True)>
Public Shared Function LoadIconMetric(
hinst As IntPtr, ' HINSTANCE optional
<MarshalAs(UnmanagedType.LPWStr)> pszName As String, ' LPCWSTR
lims As Integer, ' _LI_METRIC
phico As IntPtr ' HICON* out
) As Integer
End Function' hinst : HINSTANCE optional
' pszName : LPCWSTR
' lims : _LI_METRIC
' phico : HICON* out
Declare PtrSafe Function LoadIconMetric Lib "comctl32" ( _
ByVal hinst As LongPtr, _
ByVal pszName As LongPtr, _
ByVal lims As Long, _
ByVal phico As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
LoadIconMetric = ctypes.windll.comctl32.LoadIconMetric
LoadIconMetric.restype = ctypes.c_int
LoadIconMetric.argtypes = [
wintypes.HANDLE, # hinst : HINSTANCE optional
wintypes.LPCWSTR, # pszName : LPCWSTR
ctypes.c_int, # lims : _LI_METRIC
ctypes.c_void_p, # phico : HICON* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('COMCTL32.dll')
LoadIconMetric = Fiddle::Function.new(
lib['LoadIconMetric'],
[
Fiddle::TYPE_VOIDP, # hinst : HINSTANCE optional
Fiddle::TYPE_VOIDP, # pszName : LPCWSTR
Fiddle::TYPE_INT, # lims : _LI_METRIC
Fiddle::TYPE_VOIDP, # phico : HICON* out
],
Fiddle::TYPE_INT)#[link(name = "comctl32")]
extern "system" {
fn LoadIconMetric(
hinst: *mut core::ffi::c_void, // HINSTANCE optional
pszName: *const u16, // LPCWSTR
lims: i32, // _LI_METRIC
phico: *mut *mut core::ffi::c_void // HICON* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("COMCTL32.dll")]
public static extern int LoadIconMetric(IntPtr hinst, [MarshalAs(UnmanagedType.LPWStr)] string pszName, int lims, IntPtr phico);
"@
$api = Add-Type -MemberDefinition $sig -Name 'COMCTL32_LoadIconMetric' -Namespace Win32 -PassThru
# $api::LoadIconMetric(hinst, pszName, lims, phico)#uselib "COMCTL32.dll"
#func global LoadIconMetric "LoadIconMetric" sptr, sptr, sptr, sptr
; LoadIconMetric hinst, pszName, lims, phico ; 戻り値は stat
; hinst : HINSTANCE optional -> "sptr"
; pszName : LPCWSTR -> "sptr"
; lims : _LI_METRIC -> "sptr"
; phico : HICON* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "COMCTL32.dll"
#cfunc global LoadIconMetric "LoadIconMetric" sptr, wstr, int, sptr
; res = LoadIconMetric(hinst, pszName, lims, phico)
; hinst : HINSTANCE optional -> "sptr"
; pszName : LPCWSTR -> "wstr"
; lims : _LI_METRIC -> "int"
; phico : HICON* out -> "sptr"; HRESULT LoadIconMetric(HINSTANCE hinst, LPCWSTR pszName, _LI_METRIC lims, HICON* phico)
#uselib "COMCTL32.dll"
#cfunc global LoadIconMetric "LoadIconMetric" intptr, wstr, int, intptr
; res = LoadIconMetric(hinst, pszName, lims, phico)
; hinst : HINSTANCE optional -> "intptr"
; pszName : LPCWSTR -> "wstr"
; lims : _LI_METRIC -> "int"
; phico : HICON* out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
procLoadIconMetric = comctl32.NewProc("LoadIconMetric")
)
// hinst (HINSTANCE optional), pszName (LPCWSTR), lims (_LI_METRIC), phico (HICON* out)
r1, _, err := procLoadIconMetric.Call(
uintptr(hinst),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszName))),
uintptr(lims),
uintptr(phico),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction LoadIconMetric(
hinst: THandle; // HINSTANCE optional
pszName: PWideChar; // LPCWSTR
lims: Integer; // _LI_METRIC
phico: Pointer // HICON* out
): Integer; stdcall;
external 'COMCTL32.dll' name 'LoadIconMetric';result := DllCall("COMCTL32\LoadIconMetric"
, "Ptr", hinst ; HINSTANCE optional
, "WStr", pszName ; LPCWSTR
, "Int", lims ; _LI_METRIC
, "Ptr", phico ; HICON* out
, "Int") ; return: HRESULT●LoadIconMetric(hinst, pszName, lims, phico) = DLL("COMCTL32.dll", "int LoadIconMetric(void*, char*, int, void*)")
# 呼び出し: LoadIconMetric(hinst, pszName, lims, phico)
# hinst : HINSTANCE optional -> "void*"
# pszName : LPCWSTR -> "char*"
# lims : _LI_METRIC -> "int"
# phico : HICON* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。