ホーム › System.Ole › OleMetafilePictFromIconAndLabel
OleMetafilePictFromIconAndLabel
関数アイコンとラベルからメタファイルピクチャを作成する。
シグネチャ
// ole32.dll
#include <windows.h>
HGLOBAL OleMetafilePictFromIconAndLabel(
HICON hIcon,
LPWSTR lpszLabel,
LPWSTR lpszSourceFile,
DWORD iIconIndex
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hIcon | HICON | in |
| lpszLabel | LPWSTR | in |
| lpszSourceFile | LPWSTR | in |
| iIconIndex | DWORD | in |
戻り値の型: HGLOBAL
各言語での呼び出し定義
// ole32.dll
#include <windows.h>
HGLOBAL OleMetafilePictFromIconAndLabel(
HICON hIcon,
LPWSTR lpszLabel,
LPWSTR lpszSourceFile,
DWORD iIconIndex
);[DllImport("ole32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr OleMetafilePictFromIconAndLabel(
IntPtr hIcon, // HICON
[MarshalAs(UnmanagedType.LPWStr)] string lpszLabel, // LPWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpszSourceFile, // LPWSTR
uint iIconIndex // DWORD
);<DllImport("ole32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function OleMetafilePictFromIconAndLabel(
hIcon As IntPtr, ' HICON
<MarshalAs(UnmanagedType.LPWStr)> lpszLabel As String, ' LPWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpszSourceFile As String, ' LPWSTR
iIconIndex As UInteger ' DWORD
) As IntPtr
End Function' hIcon : HICON
' lpszLabel : LPWSTR
' lpszSourceFile : LPWSTR
' iIconIndex : DWORD
Declare PtrSafe Function OleMetafilePictFromIconAndLabel Lib "ole32" ( _
ByVal hIcon As LongPtr, _
ByVal lpszLabel As LongPtr, _
ByVal lpszSourceFile As LongPtr, _
ByVal iIconIndex As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
OleMetafilePictFromIconAndLabel = ctypes.windll.ole32.OleMetafilePictFromIconAndLabel
OleMetafilePictFromIconAndLabel.restype = ctypes.c_void_p
OleMetafilePictFromIconAndLabel.argtypes = [
wintypes.HANDLE, # hIcon : HICON
wintypes.LPCWSTR, # lpszLabel : LPWSTR
wintypes.LPCWSTR, # lpszSourceFile : LPWSTR
wintypes.DWORD, # iIconIndex : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ole32.dll')
OleMetafilePictFromIconAndLabel = Fiddle::Function.new(
lib['OleMetafilePictFromIconAndLabel'],
[
Fiddle::TYPE_VOIDP, # hIcon : HICON
Fiddle::TYPE_VOIDP, # lpszLabel : LPWSTR
Fiddle::TYPE_VOIDP, # lpszSourceFile : LPWSTR
-Fiddle::TYPE_INT, # iIconIndex : DWORD
],
Fiddle::TYPE_VOIDP)#[link(name = "ole32")]
extern "system" {
fn OleMetafilePictFromIconAndLabel(
hIcon: *mut core::ffi::c_void, // HICON
lpszLabel: *mut u16, // LPWSTR
lpszSourceFile: *mut u16, // LPWSTR
iIconIndex: u32 // DWORD
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ole32.dll", SetLastError = true)]
public static extern IntPtr OleMetafilePictFromIconAndLabel(IntPtr hIcon, [MarshalAs(UnmanagedType.LPWStr)] string lpszLabel, [MarshalAs(UnmanagedType.LPWStr)] string lpszSourceFile, uint iIconIndex);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ole32_OleMetafilePictFromIconAndLabel' -Namespace Win32 -PassThru
# $api::OleMetafilePictFromIconAndLabel(hIcon, lpszLabel, lpszSourceFile, iIconIndex)#uselib "ole32.dll"
#func global OleMetafilePictFromIconAndLabel "OleMetafilePictFromIconAndLabel" sptr, sptr, sptr, sptr
; OleMetafilePictFromIconAndLabel hIcon, lpszLabel, lpszSourceFile, iIconIndex ; 戻り値は stat
; hIcon : HICON -> "sptr"
; lpszLabel : LPWSTR -> "sptr"
; lpszSourceFile : LPWSTR -> "sptr"
; iIconIndex : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ole32.dll"
#cfunc global OleMetafilePictFromIconAndLabel "OleMetafilePictFromIconAndLabel" sptr, wstr, wstr, int
; res = OleMetafilePictFromIconAndLabel(hIcon, lpszLabel, lpszSourceFile, iIconIndex)
; hIcon : HICON -> "sptr"
; lpszLabel : LPWSTR -> "wstr"
; lpszSourceFile : LPWSTR -> "wstr"
; iIconIndex : DWORD -> "int"; HGLOBAL OleMetafilePictFromIconAndLabel(HICON hIcon, LPWSTR lpszLabel, LPWSTR lpszSourceFile, DWORD iIconIndex)
#uselib "ole32.dll"
#cfunc global OleMetafilePictFromIconAndLabel "OleMetafilePictFromIconAndLabel" intptr, wstr, wstr, int
; res = OleMetafilePictFromIconAndLabel(hIcon, lpszLabel, lpszSourceFile, iIconIndex)
; hIcon : HICON -> "intptr"
; lpszLabel : LPWSTR -> "wstr"
; lpszSourceFile : LPWSTR -> "wstr"
; iIconIndex : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ole32 = windows.NewLazySystemDLL("ole32.dll")
procOleMetafilePictFromIconAndLabel = ole32.NewProc("OleMetafilePictFromIconAndLabel")
)
// hIcon (HICON), lpszLabel (LPWSTR), lpszSourceFile (LPWSTR), iIconIndex (DWORD)
r1, _, err := procOleMetafilePictFromIconAndLabel.Call(
uintptr(hIcon),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszLabel))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszSourceFile))),
uintptr(iIconIndex),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HGLOBALfunction OleMetafilePictFromIconAndLabel(
hIcon: THandle; // HICON
lpszLabel: PWideChar; // LPWSTR
lpszSourceFile: PWideChar; // LPWSTR
iIconIndex: DWORD // DWORD
): THandle; stdcall;
external 'ole32.dll' name 'OleMetafilePictFromIconAndLabel';result := DllCall("ole32\OleMetafilePictFromIconAndLabel"
, "Ptr", hIcon ; HICON
, "WStr", lpszLabel ; LPWSTR
, "WStr", lpszSourceFile ; LPWSTR
, "UInt", iIconIndex ; DWORD
, "Ptr") ; return: HGLOBAL●OleMetafilePictFromIconAndLabel(hIcon, lpszLabel, lpszSourceFile, iIconIndex) = DLL("ole32.dll", "void* OleMetafilePictFromIconAndLabel(void*, char*, char*, dword)")
# 呼び出し: OleMetafilePictFromIconAndLabel(hIcon, lpszLabel, lpszSourceFile, iIconIndex)
# hIcon : HICON -> "void*"
# lpszLabel : LPWSTR -> "char*"
# lpszSourceFile : LPWSTR -> "char*"
# iIconIndex : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。