Win32 API 日本語リファレンス
ホームSystem.Com.Marshal › CoUnmarshalHresult

CoUnmarshalHresult

関数
ストリームからHRESULT値をアンマーシャリングして取り出す。
DLLOLE32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT CoUnmarshalHresult(
    IStream* pstm,
    HRESULT* phresult
);

パラメーター

名前方向
pstmIStream*in
phresultHRESULT*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

CoUnmarshalHresult = ctypes.windll.ole32.CoUnmarshalHresult
CoUnmarshalHresult.restype = ctypes.c_int
CoUnmarshalHresult.argtypes = [
    ctypes.c_void_p,  # pstm : IStream*
    ctypes.c_void_p,  # phresult : HRESULT* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	ole32 = windows.NewLazySystemDLL("OLE32.dll")
	procCoUnmarshalHresult = ole32.NewProc("CoUnmarshalHresult")
)

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