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

PrivateExtractIconsA

関数
ファイルから指定サイズのアイコンを複数抽出する(ANSI版)。
DLLUSER32.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// USER32.dll  (ANSI / -A)
#include <windows.h>

DWORD PrivateExtractIconsA(
    LPCSTR szFileName,
    INT nIconIndex,
    INT cxIcon,
    INT cyIcon,
    HICON* phicon,   // optional
    DWORD* piconid,   // optional
    DWORD nIcons,
    DWORD flags
);

パラメーター

名前方向説明
szFileNameLPCSTRinアイコンを抽出する対象ファイルのパスと名前。
nIconIndexINTin最初に抽出するアイコンの 0 から始まるインデックス。たとえばこの値が 0 の場合、関数は指定したファイル内の最初のアイコンを抽出します。
cxIconINTin取得したいアイコンの水平方向のサイズ。「解説」を参照してください。
cyIconINTin取得したいアイコンの垂直方向のサイズ。「解説」を参照してください。
phiconHICON*outoptional返されるアイコンハンドルの配列へのポインター。
piconidDWORD*outoptional現在の表示デバイスに最も適合するアイコンのリソース識別子を返すためのポインター。この形式で識別子が利用できない場合、返される識別子は 0xFFFFFFFF になります。識別子をその他の方法でも取得できない場合、返される識別子は 0 になります。
nIconsDWORDinファイルから抽出するアイコンの数。このパラメーターは .exe ファイルおよび .dll ファイルから抽出する場合にのみ有効です。
flagsDWORDinこの関数の動作を制御するフラグを指定します。これらのフラグは LoadImage 関数で使用される LR_* フラグです。

戻り値の型: DWORD

公式ドキュメント

指定したファイルから抽出したアイコンのハンドル配列を作成します。(ANSI)

戻り値

型: UINT

phicon パラメーターが NULL で、かつこの関数が成功した場合、戻り値はファイル内のアイコンの数です。関数が失敗した場合、戻り値は 0 です。

phicon パラメーターが NULL でなく、かつ関数が成功した場合、戻り値は抽出されたアイコンの数です。それ以外の場合、ファイルが見つからなければ戻り値は 0xFFFFFFFF になります。

解説(Remarks)

この関数は、実行可能ファイル (.exe)、DLL (.dll)、アイコン (.ico)、カーソル (.cur)、アニメーションカーソル (.ani)、ビットマップ (.bmp) の各ファイルから抽出を行います。Windows 3.x の 16 ビット実行可能ファイル (.exe または .dll) からの抽出もサポートされています。

cxIcon パラメーターと cyIcon パラメーターは、抽出するアイコンのサイズを指定します。最初のサイズをパラメーターの LOWORD に、2 番目のサイズを HIWORD に指定することで、2 つのサイズを抽出できます。たとえば、cxIcon と cyIcon の両方のパラメーターに MAKELONG(24, 48) を指定すると、24 と 48 の両方のサイズのアイコンが抽出されます。

PrivateExtractIcons によって抽出されたすべてのアイコンは、DestroyIcon 関数を呼び出して破棄する必要があります。

この関数は、Windows XP Service Pack 1 (SP1) および Windows Server 2003 まで、SDK のヘッダーおよびライブラリに含まれていませんでした。この関数のヘッダーファイルとインポートライブラリがない場合は、LoadLibraryGetProcAddress を使用してこの関数を呼び出すことができます。

メモ

winuser.h ヘッダーは、PrivateExtractIcons を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義します。エンコーディング非依存のエイリアスの使用と、エンコーディング非依存でないコードを混在させると、コンパイルエラーや実行時エラーを引き起こす不一致が生じる可能性があります。詳細については、関数プロトタイプの規約を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// USER32.dll  (ANSI / -A)
#include <windows.h>

DWORD PrivateExtractIconsA(
    LPCSTR szFileName,
    INT nIconIndex,
    INT cxIcon,
    INT cyIcon,
    HICON* phicon,   // optional
    DWORD* piconid,   // optional
    DWORD nIcons,
    DWORD flags
);
[DllImport("USER32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint PrivateExtractIconsA(
    [MarshalAs(UnmanagedType.LPStr)] string szFileName,   // LPCSTR
    int nIconIndex,   // INT
    int cxIcon,   // INT
    int cyIcon,   // INT
    IntPtr phicon,   // HICON* optional, out
    IntPtr piconid,   // DWORD* optional, out
    uint nIcons,   // DWORD
    uint flags   // DWORD
);
<DllImport("USER32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function PrivateExtractIconsA(
    <MarshalAs(UnmanagedType.LPStr)> szFileName As String,   ' LPCSTR
    nIconIndex As Integer,   ' INT
    cxIcon As Integer,   ' INT
    cyIcon As Integer,   ' INT
    phicon As IntPtr,   ' HICON* optional, out
    piconid As IntPtr,   ' DWORD* optional, out
    nIcons As UInteger,   ' DWORD
    flags As UInteger   ' DWORD
) As UInteger
End Function
' szFileName : LPCSTR
' nIconIndex : INT
' cxIcon : INT
' cyIcon : INT
' phicon : HICON* optional, out
' piconid : DWORD* optional, out
' nIcons : DWORD
' flags : DWORD
Declare PtrSafe Function PrivateExtractIconsA Lib "user32" ( _
    ByVal szFileName As String, _
    ByVal nIconIndex As Long, _
    ByVal cxIcon As Long, _
    ByVal cyIcon As Long, _
    ByVal phicon As LongPtr, _
    ByVal piconid As LongPtr, _
    ByVal nIcons As Long, _
    ByVal flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PrivateExtractIconsA = ctypes.windll.user32.PrivateExtractIconsA
PrivateExtractIconsA.restype = wintypes.DWORD
PrivateExtractIconsA.argtypes = [
    wintypes.LPCSTR,  # szFileName : LPCSTR
    ctypes.c_int,  # nIconIndex : INT
    ctypes.c_int,  # cxIcon : INT
    ctypes.c_int,  # cyIcon : INT
    ctypes.c_void_p,  # phicon : HICON* optional, out
    ctypes.POINTER(wintypes.DWORD),  # piconid : DWORD* optional, out
    wintypes.DWORD,  # nIcons : DWORD
    wintypes.DWORD,  # flags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
PrivateExtractIconsA = Fiddle::Function.new(
  lib['PrivateExtractIconsA'],
  [
    Fiddle::TYPE_VOIDP,  # szFileName : LPCSTR
    Fiddle::TYPE_INT,  # nIconIndex : INT
    Fiddle::TYPE_INT,  # cxIcon : INT
    Fiddle::TYPE_INT,  # cyIcon : INT
    Fiddle::TYPE_VOIDP,  # phicon : HICON* optional, out
    Fiddle::TYPE_VOIDP,  # piconid : DWORD* optional, out
    -Fiddle::TYPE_INT,  # nIcons : DWORD
    -Fiddle::TYPE_INT,  # flags : DWORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn PrivateExtractIconsA(
        szFileName: *const u8,  // LPCSTR
        nIconIndex: i32,  // INT
        cxIcon: i32,  // INT
        cyIcon: i32,  // INT
        phicon: *mut *mut core::ffi::c_void,  // HICON* optional, out
        piconid: *mut u32,  // DWORD* optional, out
        nIcons: u32,  // DWORD
        flags: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USER32.dll", CharSet = CharSet.Ansi)]
public static extern uint PrivateExtractIconsA([MarshalAs(UnmanagedType.LPStr)] string szFileName, int nIconIndex, int cxIcon, int cyIcon, IntPtr phicon, IntPtr piconid, uint nIcons, uint flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_PrivateExtractIconsA' -Namespace Win32 -PassThru
# $api::PrivateExtractIconsA(szFileName, nIconIndex, cxIcon, cyIcon, phicon, piconid, nIcons, flags)
#uselib "USER32.dll"
#func global PrivateExtractIconsA "PrivateExtractIconsA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; PrivateExtractIconsA szFileName, nIconIndex, cxIcon, cyIcon, phicon, varptr(piconid), nIcons, flags   ; 戻り値は stat
; szFileName : LPCSTR -> "sptr"
; nIconIndex : INT -> "sptr"
; cxIcon : INT -> "sptr"
; cyIcon : INT -> "sptr"
; phicon : HICON* optional, out -> "sptr"
; piconid : DWORD* optional, out -> "sptr"
; nIcons : DWORD -> "sptr"
; flags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global PrivateExtractIconsA "PrivateExtractIconsA" str, int, int, int, sptr, var, int, int
; res = PrivateExtractIconsA(szFileName, nIconIndex, cxIcon, cyIcon, phicon, piconid, nIcons, flags)
; szFileName : LPCSTR -> "str"
; nIconIndex : INT -> "int"
; cxIcon : INT -> "int"
; cyIcon : INT -> "int"
; phicon : HICON* optional, out -> "sptr"
; piconid : DWORD* optional, out -> "var"
; nIcons : DWORD -> "int"
; flags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD PrivateExtractIconsA(LPCSTR szFileName, INT nIconIndex, INT cxIcon, INT cyIcon, HICON* phicon, DWORD* piconid, DWORD nIcons, DWORD flags)
#uselib "USER32.dll"
#cfunc global PrivateExtractIconsA "PrivateExtractIconsA" str, int, int, int, intptr, var, int, int
; res = PrivateExtractIconsA(szFileName, nIconIndex, cxIcon, cyIcon, phicon, piconid, nIcons, flags)
; szFileName : LPCSTR -> "str"
; nIconIndex : INT -> "int"
; cxIcon : INT -> "int"
; cyIcon : INT -> "int"
; phicon : HICON* optional, out -> "intptr"
; piconid : DWORD* optional, out -> "var"
; nIcons : DWORD -> "int"
; flags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procPrivateExtractIconsA = user32.NewProc("PrivateExtractIconsA")
)

// szFileName (LPCSTR), nIconIndex (INT), cxIcon (INT), cyIcon (INT), phicon (HICON* optional, out), piconid (DWORD* optional, out), nIcons (DWORD), flags (DWORD)
r1, _, err := procPrivateExtractIconsA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szFileName))),
	uintptr(nIconIndex),
	uintptr(cxIcon),
	uintptr(cyIcon),
	uintptr(phicon),
	uintptr(piconid),
	uintptr(nIcons),
	uintptr(flags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function PrivateExtractIconsA(
  szFileName: PAnsiChar;   // LPCSTR
  nIconIndex: Integer;   // INT
  cxIcon: Integer;   // INT
  cyIcon: Integer;   // INT
  phicon: Pointer;   // HICON* optional, out
  piconid: Pointer;   // DWORD* optional, out
  nIcons: DWORD;   // DWORD
  flags: DWORD   // DWORD
): DWORD; stdcall;
  external 'USER32.dll' name 'PrivateExtractIconsA';
result := DllCall("USER32\PrivateExtractIconsA"
    , "AStr", szFileName   ; LPCSTR
    , "Int", nIconIndex   ; INT
    , "Int", cxIcon   ; INT
    , "Int", cyIcon   ; INT
    , "Ptr", phicon   ; HICON* optional, out
    , "Ptr", piconid   ; DWORD* optional, out
    , "UInt", nIcons   ; DWORD
    , "UInt", flags   ; DWORD
    , "UInt")   ; return: DWORD
●PrivateExtractIconsA(szFileName, nIconIndex, cxIcon, cyIcon, phicon, piconid, nIcons, flags) = DLL("USER32.dll", "dword PrivateExtractIconsA(char*, int, int, int, void*, void*, dword, dword)")
# 呼び出し: PrivateExtractIconsA(szFileName, nIconIndex, cxIcon, cyIcon, phicon, piconid, nIcons, flags)
# szFileName : LPCSTR -> "char*"
# nIconIndex : INT -> "int"
# cxIcon : INT -> "int"
# cyIcon : INT -> "int"
# phicon : HICON* optional, out -> "void*"
# piconid : DWORD* optional, out -> "void*"
# nIcons : DWORD -> "dword"
# flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "user32" fn PrivateExtractIconsA(
    szFileName: [*c]const u8, // LPCSTR
    nIconIndex: i32, // INT
    cxIcon: i32, // INT
    cyIcon: i32, // INT
    phicon: ?*anyopaque, // HICON* optional, out
    piconid: [*c]u32, // DWORD* optional, out
    nIcons: u32, // DWORD
    flags: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
proc PrivateExtractIconsA(
    szFileName: cstring,  # LPCSTR
    nIconIndex: int32,  # INT
    cxIcon: int32,  # INT
    cyIcon: int32,  # INT
    phicon: pointer,  # HICON* optional, out
    piconid: ptr uint32,  # DWORD* optional, out
    nIcons: uint32,  # DWORD
    flags: uint32  # DWORD
): uint32 {.importc: "PrivateExtractIconsA", stdcall, dynlib: "USER32.dll".}
pragma(lib, "user32");
extern(Windows)
uint PrivateExtractIconsA(
    const(char)* szFileName,   // LPCSTR
    int nIconIndex,   // INT
    int cxIcon,   // INT
    int cyIcon,   // INT
    void* phicon,   // HICON* optional, out
    uint* piconid,   // DWORD* optional, out
    uint nIcons,   // DWORD
    uint flags   // DWORD
);
ccall((:PrivateExtractIconsA, "USER32.dll"), stdcall, UInt32,
      (Cstring, Int32, Int32, Int32, Ptr{Cvoid}, Ptr{UInt32}, UInt32, UInt32),
      szFileName, nIconIndex, cxIcon, cyIcon, phicon, piconid, nIcons, flags)
# szFileName : LPCSTR -> Cstring
# nIconIndex : INT -> Int32
# cxIcon : INT -> Int32
# cyIcon : INT -> Int32
# phicon : HICON* optional, out -> Ptr{Cvoid}
# piconid : DWORD* optional, out -> Ptr{UInt32}
# nIcons : DWORD -> UInt32
# flags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t PrivateExtractIconsA(
    const char* szFileName,
    int32_t nIconIndex,
    int32_t cxIcon,
    int32_t cyIcon,
    void* phicon,
    uint32_t* piconid,
    uint32_t nIcons,
    uint32_t flags);
]]
local user32 = ffi.load("user32")
-- user32.PrivateExtractIconsA(szFileName, nIconIndex, cxIcon, cyIcon, phicon, piconid, nIcons, flags)
-- szFileName : LPCSTR
-- nIconIndex : INT
-- cxIcon : INT
-- cyIcon : INT
-- phicon : HICON* optional, out
-- piconid : DWORD* optional, out
-- nIcons : DWORD
-- flags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('USER32.dll');
const PrivateExtractIconsA = lib.func('__stdcall', 'PrivateExtractIconsA', 'uint32_t', ['str', 'int32_t', 'int32_t', 'int32_t', 'void *', 'uint32_t *', 'uint32_t', 'uint32_t']);
// PrivateExtractIconsA(szFileName, nIconIndex, cxIcon, cyIcon, phicon, piconid, nIcons, flags)
// szFileName : LPCSTR -> 'str'
// nIconIndex : INT -> 'int32_t'
// cxIcon : INT -> 'int32_t'
// cyIcon : INT -> 'int32_t'
// phicon : HICON* optional, out -> 'void *'
// piconid : DWORD* optional, out -> 'uint32_t *'
// nIcons : DWORD -> 'uint32_t'
// flags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("USER32.dll", {
  PrivateExtractIconsA: { parameters: ["buffer", "i32", "i32", "i32", "pointer", "pointer", "u32", "u32"], result: "u32" },
});
// lib.symbols.PrivateExtractIconsA(szFileName, nIconIndex, cxIcon, cyIcon, phicon, piconid, nIcons, flags)
// szFileName : LPCSTR -> "buffer"
// nIconIndex : INT -> "i32"
// cxIcon : INT -> "i32"
// cyIcon : INT -> "i32"
// phicon : HICON* optional, out -> "pointer"
// piconid : DWORD* optional, out -> "pointer"
// nIcons : DWORD -> "u32"
// flags : DWORD -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t PrivateExtractIconsA(
    const char* szFileName,
    int32_t nIconIndex,
    int32_t cxIcon,
    int32_t cyIcon,
    void* phicon,
    uint32_t* piconid,
    uint32_t nIcons,
    uint32_t flags);
C, "USER32.dll");
// $ffi->PrivateExtractIconsA(szFileName, nIconIndex, cxIcon, cyIcon, phicon, piconid, nIcons, flags);
// szFileName : LPCSTR
// nIconIndex : INT
// cxIcon : INT
// cyIcon : INT
// phicon : HICON* optional, out
// piconid : DWORD* optional, out
// nIcons : DWORD
// flags : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface User32 extends StdCallLibrary {
    User32 INSTANCE = Native.load("user32", User32.class, W32APIOptions.ASCII_OPTIONS);
    int PrivateExtractIconsA(
        String szFileName,   // LPCSTR
        int nIconIndex,   // INT
        int cxIcon,   // INT
        int cyIcon,   // INT
        Pointer phicon,   // HICON* optional, out
        IntByReference piconid,   // DWORD* optional, out
        int nIcons,   // DWORD
        int flags   // DWORD
    );
}
@[Link("user32")]
lib LibUSER32
  fun PrivateExtractIconsA = PrivateExtractIconsA(
    szFileName : UInt8*,   # LPCSTR
    nIconIndex : Int32,   # INT
    cxIcon : Int32,   # INT
    cyIcon : Int32,   # INT
    phicon : Void*,   # HICON* optional, out
    piconid : UInt32*,   # DWORD* optional, out
    nIcons : UInt32,   # DWORD
    flags : UInt32   # DWORD
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef PrivateExtractIconsANative = Uint32 Function(Pointer<Utf8>, Int32, Int32, Int32, Pointer<Void>, Pointer<Uint32>, Uint32, Uint32);
typedef PrivateExtractIconsADart = int Function(Pointer<Utf8>, int, int, int, Pointer<Void>, Pointer<Uint32>, int, int);
final PrivateExtractIconsA = DynamicLibrary.open('USER32.dll')
    .lookupFunction<PrivateExtractIconsANative, PrivateExtractIconsADart>('PrivateExtractIconsA');
// szFileName : LPCSTR -> Pointer<Utf8>
// nIconIndex : INT -> Int32
// cxIcon : INT -> Int32
// cyIcon : INT -> Int32
// phicon : HICON* optional, out -> Pointer<Void>
// piconid : DWORD* optional, out -> Pointer<Uint32>
// nIcons : DWORD -> Uint32
// flags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function PrivateExtractIconsA(
  szFileName: PAnsiChar;   // LPCSTR
  nIconIndex: Integer;   // INT
  cxIcon: Integer;   // INT
  cyIcon: Integer;   // INT
  phicon: Pointer;   // HICON* optional, out
  piconid: Pointer;   // DWORD* optional, out
  nIcons: DWORD;   // DWORD
  flags: DWORD   // DWORD
): DWORD; stdcall;
  external 'USER32.dll' name 'PrivateExtractIconsA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "PrivateExtractIconsA"
  c_PrivateExtractIconsA :: CString -> Int32 -> Int32 -> Int32 -> Ptr () -> Ptr Word32 -> Word32 -> Word32 -> IO Word32
-- szFileName : LPCSTR -> CString
-- nIconIndex : INT -> Int32
-- cxIcon : INT -> Int32
-- cyIcon : INT -> Int32
-- phicon : HICON* optional, out -> Ptr ()
-- piconid : DWORD* optional, out -> Ptr Word32
-- nIcons : DWORD -> Word32
-- flags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let privateextracticonsa =
  foreign "PrivateExtractIconsA"
    (string @-> int32_t @-> int32_t @-> int32_t @-> (ptr void) @-> (ptr uint32_t) @-> uint32_t @-> uint32_t @-> returning uint32_t)
(* szFileName : LPCSTR -> string *)
(* nIconIndex : INT -> int32_t *)
(* cxIcon : INT -> int32_t *)
(* cyIcon : INT -> int32_t *)
(* phicon : HICON* optional, out -> (ptr void) *)
(* piconid : DWORD* optional, out -> (ptr uint32_t) *)
(* nIcons : DWORD -> uint32_t *)
(* flags : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library user32 (t "USER32.dll"))
(cffi:use-foreign-library user32)

(cffi:defcfun ("PrivateExtractIconsA" private-extract-icons-a :convention :stdcall) :uint32
  (sz-file-name :string)   ; LPCSTR
  (n-icon-index :int32)   ; INT
  (cx-icon :int32)   ; INT
  (cy-icon :int32)   ; INT
  (phicon :pointer)   ; HICON* optional, out
  (piconid :pointer)   ; DWORD* optional, out
  (n-icons :uint32)   ; DWORD
  (flags :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PrivateExtractIconsA = Win32::API::More->new('USER32',
    'DWORD PrivateExtractIconsA(LPCSTR szFileName, int nIconIndex, int cxIcon, int cyIcon, HANDLE phicon, LPVOID piconid, DWORD nIcons, DWORD flags)');
# my $ret = $PrivateExtractIconsA->Call($szFileName, $nIconIndex, $cxIcon, $cyIcon, $phicon, $piconid, $nIcons, $flags);
# szFileName : LPCSTR -> LPCSTR
# nIconIndex : INT -> int
# cxIcon : INT -> int
# cyIcon : INT -> int
# phicon : HICON* optional, out -> HANDLE
# piconid : DWORD* optional, out -> LPVOID
# nIcons : DWORD -> DWORD
# flags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い
公式の関連項目