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

MQMgmtAction

関数
MSMQ管理オブジェクトに対し操作を実行する。
DLLmqrt.dll呼出規約winapi

シグネチャ

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

HRESULT MQMgmtAction(
    LPCWSTR pComputerName,   // optional
    LPCWSTR pObjectName,
    LPCWSTR pAction
);

パラメーター

名前方向
pComputerNameLPCWSTRinoptional
pObjectNameLPCWSTRin
pActionLPCWSTRin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT MQMgmtAction(
    LPCWSTR pComputerName,   // optional
    LPCWSTR pObjectName,
    LPCWSTR pAction
);
[DllImport("mqrt.dll", ExactSpelling = true)]
static extern int MQMgmtAction(
    [MarshalAs(UnmanagedType.LPWStr)] string pComputerName,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string pObjectName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pAction   // LPCWSTR
);
<DllImport("mqrt.dll", ExactSpelling:=True)>
Public Shared Function MQMgmtAction(
    <MarshalAs(UnmanagedType.LPWStr)> pComputerName As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> pObjectName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pAction As String   ' LPCWSTR
) As Integer
End Function
' pComputerName : LPCWSTR optional
' pObjectName : LPCWSTR
' pAction : LPCWSTR
Declare PtrSafe Function MQMgmtAction Lib "mqrt" ( _
    ByVal pComputerName As LongPtr, _
    ByVal pObjectName As LongPtr, _
    ByVal pAction As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MQMgmtAction = ctypes.windll.mqrt.MQMgmtAction
MQMgmtAction.restype = ctypes.c_int
MQMgmtAction.argtypes = [
    wintypes.LPCWSTR,  # pComputerName : LPCWSTR optional
    wintypes.LPCWSTR,  # pObjectName : LPCWSTR
    wintypes.LPCWSTR,  # pAction : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mqrt.dll')
MQMgmtAction = Fiddle::Function.new(
  lib['MQMgmtAction'],
  [
    Fiddle::TYPE_VOIDP,  # pComputerName : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # pObjectName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pAction : LPCWSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "mqrt")]
extern "system" {
    fn MQMgmtAction(
        pComputerName: *const u16,  // LPCWSTR optional
        pObjectName: *const u16,  // LPCWSTR
        pAction: *const u16  // LPCWSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("mqrt.dll")]
public static extern int MQMgmtAction([MarshalAs(UnmanagedType.LPWStr)] string pComputerName, [MarshalAs(UnmanagedType.LPWStr)] string pObjectName, [MarshalAs(UnmanagedType.LPWStr)] string pAction);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mqrt_MQMgmtAction' -Namespace Win32 -PassThru
# $api::MQMgmtAction(pComputerName, pObjectName, pAction)
#uselib "mqrt.dll"
#func global MQMgmtAction "MQMgmtAction" sptr, sptr, sptr
; MQMgmtAction pComputerName, pObjectName, pAction   ; 戻り値は stat
; pComputerName : LPCWSTR optional -> "sptr"
; pObjectName : LPCWSTR -> "sptr"
; pAction : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "mqrt.dll"
#cfunc global MQMgmtAction "MQMgmtAction" wstr, wstr, wstr
; res = MQMgmtAction(pComputerName, pObjectName, pAction)
; pComputerName : LPCWSTR optional -> "wstr"
; pObjectName : LPCWSTR -> "wstr"
; pAction : LPCWSTR -> "wstr"
; HRESULT MQMgmtAction(LPCWSTR pComputerName, LPCWSTR pObjectName, LPCWSTR pAction)
#uselib "mqrt.dll"
#cfunc global MQMgmtAction "MQMgmtAction" wstr, wstr, wstr
; res = MQMgmtAction(pComputerName, pObjectName, pAction)
; pComputerName : LPCWSTR optional -> "wstr"
; pObjectName : LPCWSTR -> "wstr"
; pAction : LPCWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mqrt = windows.NewLazySystemDLL("mqrt.dll")
	procMQMgmtAction = mqrt.NewProc("MQMgmtAction")
)

// pComputerName (LPCWSTR optional), pObjectName (LPCWSTR), pAction (LPCWSTR)
r1, _, err := procMQMgmtAction.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pComputerName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pObjectName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pAction))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function MQMgmtAction(
  pComputerName: PWideChar;   // LPCWSTR optional
  pObjectName: PWideChar;   // LPCWSTR
  pAction: PWideChar   // LPCWSTR
): Integer; stdcall;
  external 'mqrt.dll' name 'MQMgmtAction';
result := DllCall("mqrt\MQMgmtAction"
    , "WStr", pComputerName   ; LPCWSTR optional
    , "WStr", pObjectName   ; LPCWSTR
    , "WStr", pAction   ; LPCWSTR
    , "Int")   ; return: HRESULT
●MQMgmtAction(pComputerName, pObjectName, pAction) = DLL("mqrt.dll", "int MQMgmtAction(char*, char*, char*)")
# 呼び出し: MQMgmtAction(pComputerName, pObjectName, pAction)
# pComputerName : LPCWSTR optional -> "char*"
# pObjectName : LPCWSTR -> "char*"
# pAction : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。