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

SHGetMalloc

関数
シェルのIMallocアロケーターを取得する。
DLLSHELL32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT SHGetMalloc(
    IMalloc** ppMalloc
);

パラメーター

名前方向
ppMallocIMalloc**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT SHGetMalloc(
    IMalloc** ppMalloc
);
[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern int SHGetMalloc(
    IntPtr ppMalloc   // IMalloc** out
);
<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function SHGetMalloc(
    ppMalloc As IntPtr   ' IMalloc** out
) As Integer
End Function
' ppMalloc : IMalloc** out
Declare PtrSafe Function SHGetMalloc Lib "shell32" ( _
    ByVal ppMalloc As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SHGetMalloc = ctypes.windll.shell32.SHGetMalloc
SHGetMalloc.restype = ctypes.c_int
SHGetMalloc.argtypes = [
    ctypes.c_void_p,  # ppMalloc : IMalloc** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHELL32.dll')
SHGetMalloc = Fiddle::Function.new(
  lib['SHGetMalloc'],
  [
    Fiddle::TYPE_VOIDP,  # ppMalloc : IMalloc** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "shell32")]
extern "system" {
    fn SHGetMalloc(
        ppMalloc: *mut *mut core::ffi::c_void  // IMalloc** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHELL32.dll")]
public static extern int SHGetMalloc(IntPtr ppMalloc);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHGetMalloc' -Namespace Win32 -PassThru
# $api::SHGetMalloc(ppMalloc)
#uselib "SHELL32.dll"
#func global SHGetMalloc "SHGetMalloc" sptr
; SHGetMalloc ppMalloc   ; 戻り値は stat
; ppMalloc : IMalloc** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHELL32.dll"
#cfunc global SHGetMalloc "SHGetMalloc" sptr
; res = SHGetMalloc(ppMalloc)
; ppMalloc : IMalloc** out -> "sptr"
; HRESULT SHGetMalloc(IMalloc** ppMalloc)
#uselib "SHELL32.dll"
#cfunc global SHGetMalloc "SHGetMalloc" intptr
; res = SHGetMalloc(ppMalloc)
; ppMalloc : IMalloc** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procSHGetMalloc = shell32.NewProc("SHGetMalloc")
)

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