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

CreateIconIndirect

関数
ICONINFO構造体の情報からアイコンを作成する。
DLLUSER32.dll呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

HICON CreateIconIndirect(
    ICONINFO* piconinfo
);

パラメーター

名前方向
piconinfoICONINFO*in

戻り値の型: HICON

各言語での呼び出し定義

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

HICON CreateIconIndirect(
    ICONINFO* piconinfo
);
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateIconIndirect(
    IntPtr piconinfo   // ICONINFO*
);
<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateIconIndirect(
    piconinfo As IntPtr   ' ICONINFO*
) As IntPtr
End Function
' piconinfo : ICONINFO*
Declare PtrSafe Function CreateIconIndirect Lib "user32" ( _
    ByVal piconinfo As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateIconIndirect = ctypes.windll.user32.CreateIconIndirect
CreateIconIndirect.restype = ctypes.c_void_p
CreateIconIndirect.argtypes = [
    ctypes.c_void_p,  # piconinfo : ICONINFO*
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
CreateIconIndirect = Fiddle::Function.new(
  lib['CreateIconIndirect'],
  [
    Fiddle::TYPE_VOIDP,  # piconinfo : ICONINFO*
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "user32")]
extern "system" {
    fn CreateIconIndirect(
        piconinfo: *mut ICONINFO  // ICONINFO*
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USER32.dll", SetLastError = true)]
public static extern IntPtr CreateIconIndirect(IntPtr piconinfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_CreateIconIndirect' -Namespace Win32 -PassThru
# $api::CreateIconIndirect(piconinfo)
#uselib "USER32.dll"
#func global CreateIconIndirect "CreateIconIndirect" sptr
; CreateIconIndirect varptr(piconinfo)   ; 戻り値は stat
; piconinfo : ICONINFO* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global CreateIconIndirect "CreateIconIndirect" var
; res = CreateIconIndirect(piconinfo)
; piconinfo : ICONINFO* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HICON CreateIconIndirect(ICONINFO* piconinfo)
#uselib "USER32.dll"
#cfunc global CreateIconIndirect "CreateIconIndirect" var
; res = CreateIconIndirect(piconinfo)
; piconinfo : ICONINFO* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procCreateIconIndirect = user32.NewProc("CreateIconIndirect")
)

// piconinfo (ICONINFO*)
r1, _, err := procCreateIconIndirect.Call(
	uintptr(piconinfo),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HICON
function CreateIconIndirect(
  piconinfo: Pointer   // ICONINFO*
): THandle; stdcall;
  external 'USER32.dll' name 'CreateIconIndirect';
result := DllCall("USER32\CreateIconIndirect"
    , "Ptr", piconinfo   ; ICONINFO*
    , "Ptr")   ; return: HICON
●CreateIconIndirect(piconinfo) = DLL("USER32.dll", "void* CreateIconIndirect(void*)")
# 呼び出し: CreateIconIndirect(piconinfo)
# piconinfo : ICONINFO* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。