ホーム › System.MessageQueuing › MQMgmtAction
MQMgmtAction
関数MSMQ管理オブジェクトに対し操作を実行する。
シグネチャ
// mqrt.dll
#include <windows.h>
HRESULT MQMgmtAction(
LPCWSTR pComputerName, // optional
LPCWSTR pObjectName,
LPCWSTR pAction
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pComputerName | LPCWSTR | inoptional | 管理アクションを実行する対象コンピューター名(ワイド文字列)。NULL可でローカルとなる。 |
| pObjectName | LPCWSTR | in | アクション対象のオブジェクト名(MACHINEやQUEUE=書式名等)を指定する。 |
| pAction | LPCWSTR | in | 実行する管理アクション名(PAUSE、RESUME、EOD_RESEND等)を指定する。 |
戻り値の型: 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 // HRESULTfunction 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)。const std = @import("std");
extern "mqrt" fn MQMgmtAction(
pComputerName: [*c]const u16, // LPCWSTR optional
pObjectName: [*c]const u16, // LPCWSTR
pAction: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;proc MQMgmtAction(
pComputerName: WideCString, # LPCWSTR optional
pObjectName: WideCString, # LPCWSTR
pAction: WideCString # LPCWSTR
): int32 {.importc: "MQMgmtAction", stdcall, dynlib: "mqrt.dll".}pragma(lib, "mqrt");
extern(Windows)
int MQMgmtAction(
const(wchar)* pComputerName, // LPCWSTR optional
const(wchar)* pObjectName, // LPCWSTR
const(wchar)* pAction // LPCWSTR
);ccall((:MQMgmtAction, "mqrt.dll"), stdcall, Int32,
(Cwstring, Cwstring, Cwstring),
pComputerName, pObjectName, pAction)
# pComputerName : LPCWSTR optional -> Cwstring
# pObjectName : LPCWSTR -> Cwstring
# pAction : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MQMgmtAction(
const uint16_t* pComputerName,
const uint16_t* pObjectName,
const uint16_t* pAction);
]]
local mqrt = ffi.load("mqrt")
-- mqrt.MQMgmtAction(pComputerName, pObjectName, pAction)
-- pComputerName : LPCWSTR optional
-- pObjectName : LPCWSTR
-- pAction : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('mqrt.dll');
const MQMgmtAction = lib.func('__stdcall', 'MQMgmtAction', 'int32_t', ['str16', 'str16', 'str16']);
// MQMgmtAction(pComputerName, pObjectName, pAction)
// pComputerName : LPCWSTR optional -> 'str16'
// pObjectName : LPCWSTR -> 'str16'
// pAction : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("mqrt.dll", {
MQMgmtAction: { parameters: ["buffer", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.MQMgmtAction(pComputerName, pObjectName, pAction)
// pComputerName : LPCWSTR optional -> "buffer"
// pObjectName : LPCWSTR -> "buffer"
// pAction : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MQMgmtAction(
const uint16_t* pComputerName,
const uint16_t* pObjectName,
const uint16_t* pAction);
C, "mqrt.dll");
// $ffi->MQMgmtAction(pComputerName, pObjectName, pAction);
// pComputerName : LPCWSTR optional
// pObjectName : LPCWSTR
// pAction : LPCWSTR
// 構造体/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 MQMgmtAction(
WString pComputerName, // LPCWSTR optional
WString pObjectName, // LPCWSTR
WString pAction // LPCWSTR
);
}@[Link("mqrt")]
lib Libmqrt
fun MQMgmtAction = MQMgmtAction(
pComputerName : UInt16*, # LPCWSTR optional
pObjectName : UInt16*, # LPCWSTR
pAction : UInt16* # LPCWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MQMgmtActionNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
typedef MQMgmtActionDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
final MQMgmtAction = DynamicLibrary.open('mqrt.dll')
.lookupFunction<MQMgmtActionNative, MQMgmtActionDart>('MQMgmtAction');
// pComputerName : LPCWSTR optional -> Pointer<Utf16>
// pObjectName : LPCWSTR -> Pointer<Utf16>
// pAction : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MQMgmtAction(
pComputerName: PWideChar; // LPCWSTR optional
pObjectName: PWideChar; // LPCWSTR
pAction: PWideChar // LPCWSTR
): Integer; stdcall;
external 'mqrt.dll' name 'MQMgmtAction';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MQMgmtAction"
c_MQMgmtAction :: CWString -> CWString -> CWString -> IO Int32
-- pComputerName : LPCWSTR optional -> CWString
-- pObjectName : LPCWSTR -> CWString
-- pAction : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mqmgmtaction =
foreign "MQMgmtAction"
((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning int32_t)
(* pComputerName : LPCWSTR optional -> (ptr uint16_t) *)
(* pObjectName : LPCWSTR -> (ptr uint16_t) *)
(* pAction : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mqrt (t "mqrt.dll"))
(cffi:use-foreign-library mqrt)
(cffi:defcfun ("MQMgmtAction" mqmgmt-action :convention :stdcall) :int32
(p-computer-name (:string :encoding :utf-16le)) ; LPCWSTR optional
(p-object-name (:string :encoding :utf-16le)) ; LPCWSTR
(p-action (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MQMgmtAction = Win32::API::More->new('mqrt',
'int MQMgmtAction(LPCWSTR pComputerName, LPCWSTR pObjectName, LPCWSTR pAction)');
# my $ret = $MQMgmtAction->Call($pComputerName, $pObjectName, $pAction);
# pComputerName : LPCWSTR optional -> LPCWSTR
# pObjectName : LPCWSTR -> LPCWSTR
# pAction : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。