ホーム › UI.WindowsAndMessaging › PrivateExtractIconsA
PrivateExtractIconsA
関数ファイルから指定サイズのアイコンを複数抽出する(ANSI版)。
シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| szFileName | LPCSTR | in |
| nIconIndex | INT | in |
| cxIcon | INT | in |
| cyIcon | INT | in |
| phicon | HICON* | outoptional |
| piconid | DWORD* | outoptional |
| nIcons | DWORD | in |
| flags | DWORD | in |
戻り値の型: DWORD
各言語での呼び出し定義
// 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 方式にも切替可。#uselib "USER32.dll" #cfunc global PrivateExtractIconsA "PrivateExtractIconsA" str, int, int, int, sptr, sptr, int, int ; res = PrivateExtractIconsA(szFileName, nIconIndex, cxIcon, cyIcon, phicon, varptr(piconid), nIcons, flags) ; szFileName : LPCSTR -> "str" ; nIconIndex : INT -> "int" ; cxIcon : INT -> "int" ; cyIcon : INT -> "int" ; phicon : HICON* optional, out -> "sptr" ; piconid : DWORD* optional, out -> "sptr" ; nIcons : DWORD -> "int" ; flags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr, int, int ; res = PrivateExtractIconsA(szFileName, nIconIndex, cxIcon, cyIcon, phicon, varptr(piconid), nIcons, flags) ; szFileName : LPCSTR -> "str" ; nIconIndex : INT -> "int" ; cxIcon : INT -> "int" ; cyIcon : INT -> "int" ; phicon : HICON* optional, out -> "intptr" ; piconid : DWORD* optional, out -> "intptr" ; nIcons : DWORD -> "int" ; flags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // DWORDfunction 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)。