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受信対象メッセージを一意に識別するルックアップIDを指定する。
dwLookupActionDWORDinルックアップ動作。MQ_LOOKUP_RECEIVE_CURRENTやMQ_LOOKUP_PEEK_NEXT等を指定する。
pMessagePropsMQMSGPROPS*inoutoptional受信したメッセージのプロパティを受け取るMQMSGPROPS構造体へのポインタを指定する。
lpOverlappedOVERLAPPED*inoutoptional非同期受信に使うOVERLAPPED構造体へのポインタ。NULL可で同期受信となる。
fnReceiveCallbackPMQRECEIVECALLBACKinoptional非同期完了時に呼ばれる受信コールバック関数へのポインタ。NULL可。
pTransactionITransaction*inoptional受信を実行するトランザクションへのITransactionポインタ。NULLや特殊定数で非トランザクションとなる。

戻り値の型: 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)。
const std = @import("std");

extern "mqrt" fn MQReceiveMessageByLookupId(
    hSource: isize, // INT_PTR
    ullLookupId: u64, // ULONGLONG
    dwLookupAction: u32, // DWORD
    pMessageProps: [*c]MQMSGPROPS, // MQMSGPROPS* optional, in/out
    lpOverlapped: [*c]OVERLAPPED, // OVERLAPPED* optional, in/out
    fnReceiveCallback: ?*anyopaque, // PMQRECEIVECALLBACK optional
    pTransaction: ?*anyopaque // ITransaction* optional
) callconv(std.os.windows.WINAPI) i32;
proc MQReceiveMessageByLookupId(
    hSource: int,  # INT_PTR
    ullLookupId: uint64,  # ULONGLONG
    dwLookupAction: uint32,  # DWORD
    pMessageProps: ptr MQMSGPROPS,  # MQMSGPROPS* optional, in/out
    lpOverlapped: ptr OVERLAPPED,  # OVERLAPPED* optional, in/out
    fnReceiveCallback: pointer,  # PMQRECEIVECALLBACK optional
    pTransaction: pointer  # ITransaction* optional
): int32 {.importc: "MQReceiveMessageByLookupId", stdcall, dynlib: "mqrt.dll".}
pragma(lib, "mqrt");
extern(Windows)
int MQReceiveMessageByLookupId(
    ptrdiff_t hSource,   // INT_PTR
    ulong ullLookupId,   // ULONGLONG
    uint dwLookupAction,   // DWORD
    MQMSGPROPS* pMessageProps,   // MQMSGPROPS* optional, in/out
    OVERLAPPED* lpOverlapped,   // OVERLAPPED* optional, in/out
    void* fnReceiveCallback,   // PMQRECEIVECALLBACK optional
    void* pTransaction   // ITransaction* optional
);
ccall((:MQReceiveMessageByLookupId, "mqrt.dll"), stdcall, Int32,
      (Int, UInt64, UInt32, Ptr{MQMSGPROPS}, Ptr{OVERLAPPED}, Ptr{Cvoid}, Ptr{Cvoid}),
      hSource, ullLookupId, dwLookupAction, pMessageProps, lpOverlapped, fnReceiveCallback, pTransaction)
# hSource : INT_PTR -> Int
# ullLookupId : ULONGLONG -> UInt64
# dwLookupAction : DWORD -> UInt32
# pMessageProps : MQMSGPROPS* optional, in/out -> Ptr{MQMSGPROPS}
# lpOverlapped : OVERLAPPED* optional, in/out -> Ptr{OVERLAPPED}
# fnReceiveCallback : PMQRECEIVECALLBACK optional -> Ptr{Cvoid}
# pTransaction : ITransaction* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t MQReceiveMessageByLookupId(
    intptr_t hSource,
    uint64_t ullLookupId,
    uint32_t dwLookupAction,
    void* pMessageProps,
    void* lpOverlapped,
    void* fnReceiveCallback,
    void* pTransaction);
]]
local mqrt = ffi.load("mqrt")
-- mqrt.MQReceiveMessageByLookupId(hSource, ullLookupId, dwLookupAction, pMessageProps, lpOverlapped, fnReceiveCallback, pTransaction)
-- hSource : INT_PTR
-- ullLookupId : ULONGLONG
-- dwLookupAction : DWORD
-- pMessageProps : MQMSGPROPS* optional, in/out
-- lpOverlapped : OVERLAPPED* optional, in/out
-- fnReceiveCallback : PMQRECEIVECALLBACK optional
-- pTransaction : ITransaction* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('mqrt.dll');
const MQReceiveMessageByLookupId = lib.func('__stdcall', 'MQReceiveMessageByLookupId', 'int32_t', ['intptr_t', 'uint64_t', 'uint32_t', 'void *', 'void *', 'void *', 'void *']);
// MQReceiveMessageByLookupId(hSource, ullLookupId, dwLookupAction, pMessageProps, lpOverlapped, fnReceiveCallback, pTransaction)
// hSource : INT_PTR -> 'intptr_t'
// ullLookupId : ULONGLONG -> 'uint64_t'
// dwLookupAction : DWORD -> 'uint32_t'
// pMessageProps : MQMSGPROPS* optional, in/out -> 'void *'
// lpOverlapped : OVERLAPPED* optional, in/out -> 'void *'
// fnReceiveCallback : PMQRECEIVECALLBACK optional -> 'void *'
// pTransaction : ITransaction* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("mqrt.dll", {
  MQReceiveMessageByLookupId: { parameters: ["isize", "u64", "u32", "pointer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.MQReceiveMessageByLookupId(hSource, ullLookupId, dwLookupAction, pMessageProps, lpOverlapped, fnReceiveCallback, pTransaction)
// hSource : INT_PTR -> "isize"
// ullLookupId : ULONGLONG -> "u64"
// dwLookupAction : DWORD -> "u32"
// pMessageProps : MQMSGPROPS* optional, in/out -> "pointer"
// lpOverlapped : OVERLAPPED* optional, in/out -> "pointer"
// fnReceiveCallback : PMQRECEIVECALLBACK optional -> "pointer"
// pTransaction : ITransaction* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t MQReceiveMessageByLookupId(
    intptr_t hSource,
    uint64_t ullLookupId,
    uint32_t dwLookupAction,
    void* pMessageProps,
    void* lpOverlapped,
    void* fnReceiveCallback,
    void* pTransaction);
C, "mqrt.dll");
// $ffi->MQReceiveMessageByLookupId(hSource, ullLookupId, dwLookupAction, pMessageProps, lpOverlapped, fnReceiveCallback, pTransaction);
// hSource : INT_PTR
// ullLookupId : ULONGLONG
// dwLookupAction : DWORD
// pMessageProps : MQMSGPROPS* optional, in/out
// lpOverlapped : OVERLAPPED* optional, in/out
// fnReceiveCallback : PMQRECEIVECALLBACK optional
// pTransaction : ITransaction* optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Mqrt extends StdCallLibrary {
    Mqrt INSTANCE = Native.load("mqrt", Mqrt.class);
    int MQReceiveMessageByLookupId(
        long hSource,   // INT_PTR
        long ullLookupId,   // ULONGLONG
        int dwLookupAction,   // DWORD
        Pointer pMessageProps,   // MQMSGPROPS* optional, in/out
        Pointer lpOverlapped,   // OVERLAPPED* optional, in/out
        Callback fnReceiveCallback,   // PMQRECEIVECALLBACK optional
        Pointer pTransaction   // ITransaction* optional
    );
}
@[Link("mqrt")]
lib Libmqrt
  fun MQReceiveMessageByLookupId = MQReceiveMessageByLookupId(
    hSource : LibC::SSizeT,   # INT_PTR
    ullLookupId : UInt64,   # ULONGLONG
    dwLookupAction : UInt32,   # DWORD
    pMessageProps : MQMSGPROPS*,   # MQMSGPROPS* optional, in/out
    lpOverlapped : OVERLAPPED*,   # OVERLAPPED* optional, in/out
    fnReceiveCallback : Void*,   # PMQRECEIVECALLBACK optional
    pTransaction : Void*   # ITransaction* optional
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef MQReceiveMessageByLookupIdNative = Int32 Function(IntPtr, Uint64, Uint32, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef MQReceiveMessageByLookupIdDart = int Function(int, int, int, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final MQReceiveMessageByLookupId = DynamicLibrary.open('mqrt.dll')
    .lookupFunction<MQReceiveMessageByLookupIdNative, MQReceiveMessageByLookupIdDart>('MQReceiveMessageByLookupId');
// hSource : INT_PTR -> IntPtr
// ullLookupId : ULONGLONG -> Uint64
// dwLookupAction : DWORD -> Uint32
// pMessageProps : MQMSGPROPS* optional, in/out -> Pointer<Void>
// lpOverlapped : OVERLAPPED* optional, in/out -> Pointer<Void>
// fnReceiveCallback : PMQRECEIVECALLBACK optional -> Pointer<Void>
// pTransaction : ITransaction* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MQReceiveMessageByLookupId"
  c_MQReceiveMessageByLookupId :: CIntPtr -> Word64 -> Word32 -> Ptr () -> Ptr () -> Ptr () -> Ptr () -> IO Int32
-- hSource : INT_PTR -> CIntPtr
-- ullLookupId : ULONGLONG -> Word64
-- dwLookupAction : DWORD -> Word32
-- pMessageProps : MQMSGPROPS* optional, in/out -> Ptr ()
-- lpOverlapped : OVERLAPPED* optional, in/out -> Ptr ()
-- fnReceiveCallback : PMQRECEIVECALLBACK optional -> Ptr ()
-- pTransaction : ITransaction* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mqreceivemessagebylookupid =
  foreign "MQReceiveMessageByLookupId"
    (intptr_t @-> uint64_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* hSource : INT_PTR -> intptr_t *)
(* ullLookupId : ULONGLONG -> uint64_t *)
(* dwLookupAction : DWORD -> uint32_t *)
(* pMessageProps : MQMSGPROPS* optional, in/out -> (ptr void) *)
(* lpOverlapped : OVERLAPPED* optional, in/out -> (ptr void) *)
(* fnReceiveCallback : PMQRECEIVECALLBACK optional -> (ptr void) *)
(* pTransaction : ITransaction* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mqrt (t "mqrt.dll"))
(cffi:use-foreign-library mqrt)

(cffi:defcfun ("MQReceiveMessageByLookupId" mqreceive-message-by-lookup-id :convention :stdcall) :int32
  (h-source :int64)   ; INT_PTR
  (ull-lookup-id :uint64)   ; ULONGLONG
  (dw-lookup-action :uint32)   ; DWORD
  (p-message-props :pointer)   ; MQMSGPROPS* optional, in/out
  (lp-overlapped :pointer)   ; OVERLAPPED* optional, in/out
  (fn-receive-callback :pointer)   ; PMQRECEIVECALLBACK optional
  (p-transaction :pointer))   ; ITransaction* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MQReceiveMessageByLookupId = Win32::API::More->new('mqrt',
    'int MQReceiveMessageByLookupId(LPARAM hSource, UINT64 ullLookupId, DWORD dwLookupAction, LPVOID pMessageProps, LPVOID lpOverlapped, LPVOID fnReceiveCallback, LPVOID pTransaction)');
# my $ret = $MQReceiveMessageByLookupId->Call($hSource, $ullLookupId, $dwLookupAction, $pMessageProps, $lpOverlapped, $fnReceiveCallback, $pTransaction);
# hSource : INT_PTR -> LPARAM
# ullLookupId : ULONGLONG -> UINT64
# dwLookupAction : DWORD -> DWORD
# pMessageProps : MQMSGPROPS* optional, in/out -> LPVOID
# lpOverlapped : OVERLAPPED* optional, in/out -> LPVOID
# fnReceiveCallback : PMQRECEIVECALLBACK optional -> LPVOID
# pTransaction : ITransaction* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

使用する型