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

MQSendMessage

関数
指定した宛先キューへメッセージを送信する。
DLLmqrt.dll呼出規約winapi

シグネチャ

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

HRESULT MQSendMessage(
    INT_PTR hDestinationQueue,
    MQMSGPROPS* pMessageProps,
    ITransaction* pTransaction   // optional
);

パラメーター

名前方向
hDestinationQueueINT_PTRin
pMessagePropsMQMSGPROPS*in
pTransactionITransaction*inoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT MQSendMessage(
    INT_PTR hDestinationQueue,
    MQMSGPROPS* pMessageProps,
    ITransaction* pTransaction   // optional
);
[DllImport("mqrt.dll", ExactSpelling = true)]
static extern int MQSendMessage(
    IntPtr hDestinationQueue,   // INT_PTR
    IntPtr pMessageProps,   // MQMSGPROPS*
    IntPtr pTransaction   // ITransaction* optional
);
<DllImport("mqrt.dll", ExactSpelling:=True)>
Public Shared Function MQSendMessage(
    hDestinationQueue As IntPtr,   ' INT_PTR
    pMessageProps As IntPtr,   ' MQMSGPROPS*
    pTransaction As IntPtr   ' ITransaction* optional
) As Integer
End Function
' hDestinationQueue : INT_PTR
' pMessageProps : MQMSGPROPS*
' pTransaction : ITransaction* optional
Declare PtrSafe Function MQSendMessage Lib "mqrt" ( _
    ByVal hDestinationQueue As LongPtr, _
    ByVal pMessageProps 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

MQSendMessage = ctypes.windll.mqrt.MQSendMessage
MQSendMessage.restype = ctypes.c_int
MQSendMessage.argtypes = [
    ctypes.c_ssize_t,  # hDestinationQueue : INT_PTR
    ctypes.c_void_p,  # pMessageProps : MQMSGPROPS*
    ctypes.c_void_p,  # pTransaction : ITransaction* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mqrt.dll')
MQSendMessage = Fiddle::Function.new(
  lib['MQSendMessage'],
  [
    Fiddle::TYPE_INTPTR_T,  # hDestinationQueue : INT_PTR
    Fiddle::TYPE_VOIDP,  # pMessageProps : MQMSGPROPS*
    Fiddle::TYPE_VOIDP,  # pTransaction : ITransaction* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "mqrt")]
extern "system" {
    fn MQSendMessage(
        hDestinationQueue: isize,  // INT_PTR
        pMessageProps: *mut MQMSGPROPS,  // MQMSGPROPS*
        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 MQSendMessage(IntPtr hDestinationQueue, IntPtr pMessageProps, IntPtr pTransaction);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mqrt_MQSendMessage' -Namespace Win32 -PassThru
# $api::MQSendMessage(hDestinationQueue, pMessageProps, pTransaction)
#uselib "mqrt.dll"
#func global MQSendMessage "MQSendMessage" sptr, sptr, sptr
; MQSendMessage hDestinationQueue, varptr(pMessageProps), pTransaction   ; 戻り値は stat
; hDestinationQueue : INT_PTR -> "sptr"
; pMessageProps : MQMSGPROPS* -> "sptr"
; pTransaction : ITransaction* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "mqrt.dll"
#cfunc global MQSendMessage "MQSendMessage" sptr, var, sptr
; res = MQSendMessage(hDestinationQueue, pMessageProps, pTransaction)
; hDestinationQueue : INT_PTR -> "sptr"
; pMessageProps : MQMSGPROPS* -> "var"
; pTransaction : ITransaction* optional -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT MQSendMessage(INT_PTR hDestinationQueue, MQMSGPROPS* pMessageProps, ITransaction* pTransaction)
#uselib "mqrt.dll"
#cfunc global MQSendMessage "MQSendMessage" intptr, var, intptr
; res = MQSendMessage(hDestinationQueue, pMessageProps, pTransaction)
; hDestinationQueue : INT_PTR -> "intptr"
; pMessageProps : MQMSGPROPS* -> "var"
; pTransaction : ITransaction* optional -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mqrt = windows.NewLazySystemDLL("mqrt.dll")
	procMQSendMessage = mqrt.NewProc("MQSendMessage")
)

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