Win32 API 日本語リファレンス
ホームUI.Controls › LoadIconWithScaleDown

LoadIconWithScaleDown

関数
指定サイズに縮小してアイコンを読み込む。
DLLCOMCTL32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// COMCTL32.dll
#include <windows.h>

HRESULT LoadIconWithScaleDown(
    HINSTANCE hinst,   // optional
    LPCWSTR pszName,
    INT cx,
    INT cy,
    HICON* phico
);

パラメーター

名前方向
hinstHINSTANCEinoptional
pszNameLPCWSTRin
cxINTin
cyINTin
phicoHICON*out

戻り値の型: HRESULT

各言語での呼び出し定義

// COMCTL32.dll
#include <windows.h>

HRESULT LoadIconWithScaleDown(
    HINSTANCE hinst,   // optional
    LPCWSTR pszName,
    INT cx,
    INT cy,
    HICON* phico
);
[DllImport("COMCTL32.dll", ExactSpelling = true)]
static extern int LoadIconWithScaleDown(
    IntPtr hinst,   // HINSTANCE optional
    [MarshalAs(UnmanagedType.LPWStr)] string pszName,   // LPCWSTR
    int cx,   // INT
    int cy,   // INT
    IntPtr phico   // HICON* out
);
<DllImport("COMCTL32.dll", ExactSpelling:=True)>
Public Shared Function LoadIconWithScaleDown(
    hinst As IntPtr,   ' HINSTANCE optional
    <MarshalAs(UnmanagedType.LPWStr)> pszName As String,   ' LPCWSTR
    cx As Integer,   ' INT
    cy As Integer,   ' INT
    phico As IntPtr   ' HICON* out
) As Integer
End Function
' hinst : HINSTANCE optional
' pszName : LPCWSTR
' cx : INT
' cy : INT
' phico : HICON* out
Declare PtrSafe Function LoadIconWithScaleDown Lib "comctl32" ( _
    ByVal hinst As LongPtr, _
    ByVal pszName As LongPtr, _
    ByVal cx As Long, _
    ByVal cy 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

LoadIconWithScaleDown = ctypes.windll.comctl32.LoadIconWithScaleDown
LoadIconWithScaleDown.restype = ctypes.c_int
LoadIconWithScaleDown.argtypes = [
    wintypes.HANDLE,  # hinst : HINSTANCE optional
    wintypes.LPCWSTR,  # pszName : LPCWSTR
    ctypes.c_int,  # cx : INT
    ctypes.c_int,  # cy : INT
    ctypes.c_void_p,  # phico : HICON* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('COMCTL32.dll')
LoadIconWithScaleDown = Fiddle::Function.new(
  lib['LoadIconWithScaleDown'],
  [
    Fiddle::TYPE_VOIDP,  # hinst : HINSTANCE optional
    Fiddle::TYPE_VOIDP,  # pszName : LPCWSTR
    Fiddle::TYPE_INT,  # cx : INT
    Fiddle::TYPE_INT,  # cy : INT
    Fiddle::TYPE_VOIDP,  # phico : HICON* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "comctl32")]
extern "system" {
    fn LoadIconWithScaleDown(
        hinst: *mut core::ffi::c_void,  // HINSTANCE optional
        pszName: *const u16,  // LPCWSTR
        cx: i32,  // INT
        cy: i32,  // INT
        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 LoadIconWithScaleDown(IntPtr hinst, [MarshalAs(UnmanagedType.LPWStr)] string pszName, int cx, int cy, IntPtr phico);
"@
$api = Add-Type -MemberDefinition $sig -Name 'COMCTL32_LoadIconWithScaleDown' -Namespace Win32 -PassThru
# $api::LoadIconWithScaleDown(hinst, pszName, cx, cy, phico)
#uselib "COMCTL32.dll"
#func global LoadIconWithScaleDown "LoadIconWithScaleDown" sptr, sptr, sptr, sptr, sptr
; LoadIconWithScaleDown hinst, pszName, cx, cy, phico   ; 戻り値は stat
; hinst : HINSTANCE optional -> "sptr"
; pszName : LPCWSTR -> "sptr"
; cx : INT -> "sptr"
; cy : INT -> "sptr"
; phico : HICON* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "COMCTL32.dll"
#cfunc global LoadIconWithScaleDown "LoadIconWithScaleDown" sptr, wstr, int, int, sptr
; res = LoadIconWithScaleDown(hinst, pszName, cx, cy, phico)
; hinst : HINSTANCE optional -> "sptr"
; pszName : LPCWSTR -> "wstr"
; cx : INT -> "int"
; cy : INT -> "int"
; phico : HICON* out -> "sptr"
; HRESULT LoadIconWithScaleDown(HINSTANCE hinst, LPCWSTR pszName, INT cx, INT cy, HICON* phico)
#uselib "COMCTL32.dll"
#cfunc global LoadIconWithScaleDown "LoadIconWithScaleDown" intptr, wstr, int, int, intptr
; res = LoadIconWithScaleDown(hinst, pszName, cx, cy, phico)
; hinst : HINSTANCE optional -> "intptr"
; pszName : LPCWSTR -> "wstr"
; cx : INT -> "int"
; cy : INT -> "int"
; phico : HICON* out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
	procLoadIconWithScaleDown = comctl32.NewProc("LoadIconWithScaleDown")
)

// hinst (HINSTANCE optional), pszName (LPCWSTR), cx (INT), cy (INT), phico (HICON* out)
r1, _, err := procLoadIconWithScaleDown.Call(
	uintptr(hinst),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszName))),
	uintptr(cx),
	uintptr(cy),
	uintptr(phico),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function LoadIconWithScaleDown(
  hinst: THandle;   // HINSTANCE optional
  pszName: PWideChar;   // LPCWSTR
  cx: Integer;   // INT
  cy: Integer;   // INT
  phico: Pointer   // HICON* out
): Integer; stdcall;
  external 'COMCTL32.dll' name 'LoadIconWithScaleDown';
result := DllCall("COMCTL32\LoadIconWithScaleDown"
    , "Ptr", hinst   ; HINSTANCE optional
    , "WStr", pszName   ; LPCWSTR
    , "Int", cx   ; INT
    , "Int", cy   ; INT
    , "Ptr", phico   ; HICON* out
    , "Int")   ; return: HRESULT
●LoadIconWithScaleDown(hinst, pszName, cx, cy, phico) = DLL("COMCTL32.dll", "int LoadIconWithScaleDown(void*, char*, int, int, void*)")
# 呼び出し: LoadIconWithScaleDown(hinst, pszName, cx, cy, phico)
# hinst : HINSTANCE optional -> "void*"
# pszName : LPCWSTR -> "char*"
# cx : INT -> "int"
# cy : INT -> "int"
# phico : HICON* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。