Win32 API 日本語リファレンス
ホームSystem.MessageQueuing › MQReceiveMessageByLookupId

MQReceiveMessageByLookupId

関数
ルックアップIDを指定してキューからメッセージを受信する。
DLLmqrt.dll呼出規約winapi

シグネチャ

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

HRESULT MQReceiveMessageByLookupId(
    INT_PTR hSource,
    ULONGLONG ullLookupId,
    DWORD dwLookupAction,
    MQMSGPROPS* pMessageProps,   // optional
    OVERLAPPED* lpOverlapped,   // optional
    PMQRECEIVECALLBACK fnReceiveCallback,   // optional
    ITransaction* pTransaction   // optional
);

パラメーター

名前方向
hSourceINT_PTRin
ullLookupIdULONGLONGin
dwLookupActionDWORDin
pMessagePropsMQMSGPROPS*inoutoptional
lpOverlappedOVERLAPPED*inoutoptional
fnReceiveCallbackPMQRECEIVECALLBACKinoptional
pTransactionITransaction*inoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT MQReceiveMessageByLookupId(
    INT_PTR hSource,
    ULONGLONG ullLookupId,
    DWORD dwLookupAction,
    MQMSGPROPS* pMessageProps,   // optional
    OVERLAPPED* lpOverlapped,   // optional
    PMQRECEIVECALLBACK fnReceiveCallback,   // optional
    ITransaction* pTransaction   // optional
);
[DllImport("mqrt.dll", ExactSpelling = true)]
static extern int MQReceiveMessageByLookupId(
    IntPtr hSource,   // INT_PTR
    ulong ullLookupId,   // ULONGLONG
    uint dwLookupAction,   // DWORD
    IntPtr pMessageProps,   // MQMSGPROPS* optional, in/out
    IntPtr lpOverlapped,   // OVERLAPPED* optional, in/out
    IntPtr fnReceiveCallback,   // PMQRECEIVECALLBACK optional
    IntPtr pTransaction   // ITransaction* optional
);
<DllImport("mqrt.dll", ExactSpelling:=True)>
Public Shared Function MQReceiveMessageByLookupId(
    hSource As IntPtr,   ' INT_PTR
    ullLookupId As ULong,   ' ULONGLONG
    dwLookupAction As UInteger,   ' DWORD
    pMessageProps As IntPtr,   ' MQMSGPROPS* optional, in/out
    lpOverlapped As IntPtr,   ' OVERLAPPED* optional, in/out
    fnReceiveCallback As IntPtr,   ' PMQRECEIVECALLBACK optional
    pTransaction As IntPtr   ' ITransaction* optional
) As Integer
End Function
' hSource : INT_PTR
' ullLookupId : ULONGLONG
' dwLookupAction : DWORD
' pMessageProps : MQMSGPROPS* optional, in/out
' lpOverlapped : OVERLAPPED* optional, in/out
' fnReceiveCallback : PMQRECEIVECALLBACK optional
' pTransaction : ITransaction* optional
Declare PtrSafe Function MQReceiveMessageByLookupId Lib "mqrt" ( _
    ByVal hSource As LongPtr, _
    ByVal ullLookupId As LongLong, _
    ByVal dwLookupAction As Long, _
    ByVal pMessageProps As LongPtr, _
    ByVal lpOverlapped As LongPtr, _
    ByVal fnReceiveCallback As LongPtr, _
    ByVal pTransaction As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MQReceiveMessageByLookupId = ctypes.windll.mqrt.MQReceiveMessageByLookupId
MQReceiveMessageByLookupId.restype = ctypes.c_int
MQReceiveMessageByLookupId.argtypes = [
    ctypes.c_ssize_t,  # hSource : INT_PTR
    ctypes.c_ulonglong,  # ullLookupId : ULONGLONG
    wintypes.DWORD,  # dwLookupAction : DWORD
    ctypes.c_void_p,  # pMessageProps : MQMSGPROPS* optional, in/out
    ctypes.c_void_p,  # lpOverlapped : OVERLAPPED* optional, in/out
    ctypes.c_void_p,  # fnReceiveCallback : PMQRECEIVECALLBACK optional
    ctypes.c_void_p,  # pTransaction : ITransaction* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mqrt.dll')
MQReceiveMessageByLookupId = Fiddle::Function.new(
  lib['MQReceiveMessageByLookupId'],
  [
    Fiddle::TYPE_INTPTR_T,  # hSource : INT_PTR
    -Fiddle::TYPE_LONG_LONG,  # ullLookupId : ULONGLONG
    -Fiddle::TYPE_INT,  # dwLookupAction : DWORD
    Fiddle::TYPE_VOIDP,  # pMessageProps : MQMSGPROPS* optional, in/out
    Fiddle::TYPE_VOIDP,  # lpOverlapped : OVERLAPPED* optional, in/out
    Fiddle::TYPE_VOIDP,  # fnReceiveCallback : PMQRECEIVECALLBACK optional
    Fiddle::TYPE_VOIDP,  # pTransaction : ITransaction* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "mqrt")]
extern "system" {
    fn MQReceiveMessageByLookupId(
        hSource: isize,  // INT_PTR
        ullLookupId: u64,  // ULONGLONG
        dwLookupAction: u32,  // DWORD
        pMessageProps: *mut MQMSGPROPS,  // MQMSGPROPS* optional, in/out
        lpOverlapped: *mut OVERLAPPED,  // OVERLAPPED* optional, in/out
        fnReceiveCallback: *const core::ffi::c_void,  // PMQRECEIVECALLBACK optional
        pTransaction: *mut core::ffi::c_void  // ITransaction* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("mqrt.dll")]
public static extern int MQReceiveMessageByLookupId(IntPtr hSource, ulong ullLookupId, uint dwLookupAction, IntPtr pMessageProps, IntPtr lpOverlapped, IntPtr fnReceiveCallback, IntPtr pTransaction);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mqrt_MQReceiveMessageByLookupId' -Namespace Win32 -PassThru
# $api::MQReceiveMessageByLookupId(hSource, ullLookupId, dwLookupAction, pMessageProps, lpOverlapped, fnReceiveCallback, pTransaction)
#uselib "mqrt.dll"
#func global MQReceiveMessageByLookupId "MQReceiveMessageByLookupId" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; MQReceiveMessageByLookupId hSource, ullLookupId, dwLookupAction, varptr(pMessageProps), varptr(lpOverlapped), fnReceiveCallback, pTransaction   ; 戻り値は stat
; hSource : INT_PTR -> "sptr"
; ullLookupId : ULONGLONG -> "sptr"
; dwLookupAction : DWORD -> "sptr"
; pMessageProps : MQMSGPROPS* optional, in/out -> "sptr"
; lpOverlapped : OVERLAPPED* optional, in/out -> "sptr"
; fnReceiveCallback : PMQRECEIVECALLBACK optional -> "sptr"
; pTransaction : ITransaction* optional -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "mqrt.dll"
#cfunc global MQReceiveMessageByLookupId "MQReceiveMessageByLookupId" sptr, int64, int, var, var, sptr, sptr
; res = MQReceiveMessageByLookupId(hSource, ullLookupId, dwLookupAction, pMessageProps, lpOverlapped, fnReceiveCallback, pTransaction)
; hSource : INT_PTR -> "sptr"
; ullLookupId : ULONGLONG -> "int64"
; dwLookupAction : DWORD -> "int"
; pMessageProps : MQMSGPROPS* optional, in/out -> "var"
; lpOverlapped : OVERLAPPED* optional, in/out -> "var"
; fnReceiveCallback : PMQRECEIVECALLBACK optional -> "sptr"
; pTransaction : ITransaction* optional -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; HRESULT MQReceiveMessageByLookupId(INT_PTR hSource, ULONGLONG ullLookupId, DWORD dwLookupAction, MQMSGPROPS* pMessageProps, OVERLAPPED* lpOverlapped, PMQRECEIVECALLBACK fnReceiveCallback, ITransaction* pTransaction)
#uselib "mqrt.dll"
#cfunc global MQReceiveMessageByLookupId "MQReceiveMessageByLookupId" intptr, int64, int, var, var, intptr, intptr
; res = MQReceiveMessageByLookupId(hSource, ullLookupId, dwLookupAction, pMessageProps, lpOverlapped, fnReceiveCallback, pTransaction)
; hSource : INT_PTR -> "intptr"
; ullLookupId : ULONGLONG -> "int64"
; dwLookupAction : DWORD -> "int"
; pMessageProps : MQMSGPROPS* optional, in/out -> "var"
; lpOverlapped : OVERLAPPED* optional, in/out -> "var"
; fnReceiveCallback : PMQRECEIVECALLBACK optional -> "intptr"
; pTransaction : ITransaction* optional -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mqrt = windows.NewLazySystemDLL("mqrt.dll")
	procMQReceiveMessageByLookupId = mqrt.NewProc("MQReceiveMessageByLookupId")
)

// hSource (INT_PTR), ullLookupId (ULONGLONG), dwLookupAction (DWORD), pMessageProps (MQMSGPROPS* optional, in/out), lpOverlapped (OVERLAPPED* optional, in/out), fnReceiveCallback (PMQRECEIVECALLBACK optional), pTransaction (ITransaction* optional)
r1, _, err := procMQReceiveMessageByLookupId.Call(
	uintptr(hSource),
	uintptr(ullLookupId),
	uintptr(dwLookupAction),
	uintptr(pMessageProps),
	uintptr(lpOverlapped),
	uintptr(fnReceiveCallback),
	uintptr(pTransaction),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function MQReceiveMessageByLookupId(
  hSource: NativeInt;   // INT_PTR
  ullLookupId: UInt64;   // ULONGLONG
  dwLookupAction: DWORD;   // DWORD
  pMessageProps: Pointer;   // MQMSGPROPS* optional, in/out
  lpOverlapped: Pointer;   // OVERLAPPED* optional, in/out
  fnReceiveCallback: Pointer;   // PMQRECEIVECALLBACK optional
  pTransaction: Pointer   // ITransaction* optional
): Integer; stdcall;
  external 'mqrt.dll' name 'MQReceiveMessageByLookupId';
result := DllCall("mqrt\MQReceiveMessageByLookupId"
    , "Ptr", hSource   ; INT_PTR
    , "Int64", ullLookupId   ; ULONGLONG
    , "UInt", dwLookupAction   ; DWORD
    , "Ptr", pMessageProps   ; MQMSGPROPS* optional, in/out
    , "Ptr", lpOverlapped   ; OVERLAPPED* optional, in/out
    , "Ptr", fnReceiveCallback   ; PMQRECEIVECALLBACK optional
    , "Ptr", pTransaction   ; ITransaction* optional
    , "Int")   ; return: HRESULT
●MQReceiveMessageByLookupId(hSource, ullLookupId, dwLookupAction, pMessageProps, lpOverlapped, fnReceiveCallback, pTransaction) = DLL("mqrt.dll", "int MQReceiveMessageByLookupId(int, qword, dword, void*, void*, void*, void*)")
# 呼び出し: MQReceiveMessageByLookupId(hSource, ullLookupId, dwLookupAction, pMessageProps, lpOverlapped, fnReceiveCallback, pTransaction)
# hSource : INT_PTR -> "int"
# ullLookupId : ULONGLONG -> "qword"
# dwLookupAction : DWORD -> "dword"
# pMessageProps : MQMSGPROPS* optional, in/out -> "void*"
# lpOverlapped : OVERLAPPED* optional, in/out -> "void*"
# fnReceiveCallback : PMQRECEIVECALLBACK optional -> "void*"
# pTransaction : ITransaction* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。