ホーム › System.MessageQueuing › MQGetMachineProperties
MQGetMachineProperties
関数指定コンピュータのMSMQプロパティを取得する。
シグネチャ
// mqrt.dll
#include <windows.h>
HRESULT MQGetMachineProperties(
LPCWSTR lpwcsMachineName, // optional
const GUID* pguidMachineId, // optional
MQQMPROPS* pQMProps
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpwcsMachineName | LPCWSTR | inoptional | プロパティを取得する対象コンピューター名(ワイド文字列)。NULL可でGUID指定となる。 |
| pguidMachineId | GUID* | inoptional | 対象コンピューターを識別するGUIDへのポインタ。NULL可でマシン名指定となる。 |
| pQMProps | MQQMPROPS* | inout | 取得するキューマネージャプロパティを受け渡すMQQMPROPS構造体へのポインタを指定する。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// mqrt.dll
#include <windows.h>
HRESULT MQGetMachineProperties(
LPCWSTR lpwcsMachineName, // optional
const GUID* pguidMachineId, // optional
MQQMPROPS* pQMProps
);[DllImport("mqrt.dll", ExactSpelling = true)]
static extern int MQGetMachineProperties(
[MarshalAs(UnmanagedType.LPWStr)] string lpwcsMachineName, // LPCWSTR optional
IntPtr pguidMachineId, // GUID* optional
IntPtr pQMProps // MQQMPROPS* in/out
);<DllImport("mqrt.dll", ExactSpelling:=True)>
Public Shared Function MQGetMachineProperties(
<MarshalAs(UnmanagedType.LPWStr)> lpwcsMachineName As String, ' LPCWSTR optional
pguidMachineId As IntPtr, ' GUID* optional
pQMProps As IntPtr ' MQQMPROPS* in/out
) As Integer
End Function' lpwcsMachineName : LPCWSTR optional
' pguidMachineId : GUID* optional
' pQMProps : MQQMPROPS* in/out
Declare PtrSafe Function MQGetMachineProperties Lib "mqrt" ( _
ByVal lpwcsMachineName As LongPtr, _
ByVal pguidMachineId As LongPtr, _
ByVal pQMProps As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MQGetMachineProperties = ctypes.windll.mqrt.MQGetMachineProperties
MQGetMachineProperties.restype = ctypes.c_int
MQGetMachineProperties.argtypes = [
wintypes.LPCWSTR, # lpwcsMachineName : LPCWSTR optional
ctypes.c_void_p, # pguidMachineId : GUID* optional
ctypes.c_void_p, # pQMProps : MQQMPROPS* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('mqrt.dll')
MQGetMachineProperties = Fiddle::Function.new(
lib['MQGetMachineProperties'],
[
Fiddle::TYPE_VOIDP, # lpwcsMachineName : LPCWSTR optional
Fiddle::TYPE_VOIDP, # pguidMachineId : GUID* optional
Fiddle::TYPE_VOIDP, # pQMProps : MQQMPROPS* in/out
],
Fiddle::TYPE_INT)#[link(name = "mqrt")]
extern "system" {
fn MQGetMachineProperties(
lpwcsMachineName: *const u16, // LPCWSTR optional
pguidMachineId: *const GUID, // GUID* optional
pQMProps: *mut MQQMPROPS // MQQMPROPS* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("mqrt.dll")]
public static extern int MQGetMachineProperties([MarshalAs(UnmanagedType.LPWStr)] string lpwcsMachineName, IntPtr pguidMachineId, IntPtr pQMProps);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mqrt_MQGetMachineProperties' -Namespace Win32 -PassThru
# $api::MQGetMachineProperties(lpwcsMachineName, pguidMachineId, pQMProps)#uselib "mqrt.dll"
#func global MQGetMachineProperties "MQGetMachineProperties" sptr, sptr, sptr
; MQGetMachineProperties lpwcsMachineName, varptr(pguidMachineId), varptr(pQMProps) ; 戻り値は stat
; lpwcsMachineName : LPCWSTR optional -> "sptr"
; pguidMachineId : GUID* optional -> "sptr"
; pQMProps : MQQMPROPS* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "mqrt.dll" #cfunc global MQGetMachineProperties "MQGetMachineProperties" wstr, var, var ; res = MQGetMachineProperties(lpwcsMachineName, pguidMachineId, pQMProps) ; lpwcsMachineName : LPCWSTR optional -> "wstr" ; pguidMachineId : GUID* optional -> "var" ; pQMProps : MQQMPROPS* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "mqrt.dll" #cfunc global MQGetMachineProperties "MQGetMachineProperties" wstr, sptr, sptr ; res = MQGetMachineProperties(lpwcsMachineName, varptr(pguidMachineId), varptr(pQMProps)) ; lpwcsMachineName : LPCWSTR optional -> "wstr" ; pguidMachineId : GUID* optional -> "sptr" ; pQMProps : MQQMPROPS* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT MQGetMachineProperties(LPCWSTR lpwcsMachineName, GUID* pguidMachineId, MQQMPROPS* pQMProps) #uselib "mqrt.dll" #cfunc global MQGetMachineProperties "MQGetMachineProperties" wstr, var, var ; res = MQGetMachineProperties(lpwcsMachineName, pguidMachineId, pQMProps) ; lpwcsMachineName : LPCWSTR optional -> "wstr" ; pguidMachineId : GUID* optional -> "var" ; pQMProps : MQQMPROPS* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT MQGetMachineProperties(LPCWSTR lpwcsMachineName, GUID* pguidMachineId, MQQMPROPS* pQMProps) #uselib "mqrt.dll" #cfunc global MQGetMachineProperties "MQGetMachineProperties" wstr, intptr, intptr ; res = MQGetMachineProperties(lpwcsMachineName, varptr(pguidMachineId), varptr(pQMProps)) ; lpwcsMachineName : LPCWSTR optional -> "wstr" ; pguidMachineId : GUID* optional -> "intptr" ; pQMProps : MQQMPROPS* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mqrt = windows.NewLazySystemDLL("mqrt.dll")
procMQGetMachineProperties = mqrt.NewProc("MQGetMachineProperties")
)
// lpwcsMachineName (LPCWSTR optional), pguidMachineId (GUID* optional), pQMProps (MQQMPROPS* in/out)
r1, _, err := procMQGetMachineProperties.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpwcsMachineName))),
uintptr(pguidMachineId),
uintptr(pQMProps),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction MQGetMachineProperties(
lpwcsMachineName: PWideChar; // LPCWSTR optional
pguidMachineId: PGUID; // GUID* optional
pQMProps: Pointer // MQQMPROPS* in/out
): Integer; stdcall;
external 'mqrt.dll' name 'MQGetMachineProperties';result := DllCall("mqrt\MQGetMachineProperties"
, "WStr", lpwcsMachineName ; LPCWSTR optional
, "Ptr", pguidMachineId ; GUID* optional
, "Ptr", pQMProps ; MQQMPROPS* in/out
, "Int") ; return: HRESULT●MQGetMachineProperties(lpwcsMachineName, pguidMachineId, pQMProps) = DLL("mqrt.dll", "int MQGetMachineProperties(char*, void*, void*)")
# 呼び出し: MQGetMachineProperties(lpwcsMachineName, pguidMachineId, pQMProps)
# lpwcsMachineName : LPCWSTR optional -> "char*"
# pguidMachineId : GUID* optional -> "void*"
# pQMProps : MQQMPROPS* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mqrt" fn MQGetMachineProperties(
lpwcsMachineName: [*c]const u16, // LPCWSTR optional
pguidMachineId: [*c]GUID, // GUID* optional
pQMProps: [*c]MQQMPROPS // MQQMPROPS* in/out
) callconv(std.os.windows.WINAPI) i32;proc MQGetMachineProperties(
lpwcsMachineName: WideCString, # LPCWSTR optional
pguidMachineId: ptr GUID, # GUID* optional
pQMProps: ptr MQQMPROPS # MQQMPROPS* in/out
): int32 {.importc: "MQGetMachineProperties", stdcall, dynlib: "mqrt.dll".}pragma(lib, "mqrt");
extern(Windows)
int MQGetMachineProperties(
const(wchar)* lpwcsMachineName, // LPCWSTR optional
GUID* pguidMachineId, // GUID* optional
MQQMPROPS* pQMProps // MQQMPROPS* in/out
);ccall((:MQGetMachineProperties, "mqrt.dll"), stdcall, Int32,
(Cwstring, Ptr{GUID}, Ptr{MQQMPROPS}),
lpwcsMachineName, pguidMachineId, pQMProps)
# lpwcsMachineName : LPCWSTR optional -> Cwstring
# pguidMachineId : GUID* optional -> Ptr{GUID}
# pQMProps : MQQMPROPS* in/out -> Ptr{MQQMPROPS}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MQGetMachineProperties(
const uint16_t* lpwcsMachineName,
void* pguidMachineId,
void* pQMProps);
]]
local mqrt = ffi.load("mqrt")
-- mqrt.MQGetMachineProperties(lpwcsMachineName, pguidMachineId, pQMProps)
-- lpwcsMachineName : LPCWSTR optional
-- pguidMachineId : GUID* optional
-- pQMProps : MQQMPROPS* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('mqrt.dll');
const MQGetMachineProperties = lib.func('__stdcall', 'MQGetMachineProperties', 'int32_t', ['str16', 'void *', 'void *']);
// MQGetMachineProperties(lpwcsMachineName, pguidMachineId, pQMProps)
// lpwcsMachineName : LPCWSTR optional -> 'str16'
// pguidMachineId : GUID* optional -> 'void *'
// pQMProps : MQQMPROPS* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("mqrt.dll", {
MQGetMachineProperties: { parameters: ["buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.MQGetMachineProperties(lpwcsMachineName, pguidMachineId, pQMProps)
// lpwcsMachineName : LPCWSTR optional -> "buffer"
// pguidMachineId : GUID* optional -> "pointer"
// pQMProps : MQQMPROPS* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MQGetMachineProperties(
const uint16_t* lpwcsMachineName,
void* pguidMachineId,
void* pQMProps);
C, "mqrt.dll");
// $ffi->MQGetMachineProperties(lpwcsMachineName, pguidMachineId, pQMProps);
// lpwcsMachineName : LPCWSTR optional
// pguidMachineId : GUID* optional
// pQMProps : MQQMPROPS* in/out
// 構造体/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 MQGetMachineProperties(
WString lpwcsMachineName, // LPCWSTR optional
Pointer pguidMachineId, // GUID* optional
Pointer pQMProps // MQQMPROPS* in/out
);
}@[Link("mqrt")]
lib Libmqrt
fun MQGetMachineProperties = MQGetMachineProperties(
lpwcsMachineName : UInt16*, # LPCWSTR optional
pguidMachineId : GUID*, # GUID* optional
pQMProps : MQQMPROPS* # MQQMPROPS* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MQGetMachinePropertiesNative = Int32 Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
typedef MQGetMachinePropertiesDart = int Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
final MQGetMachineProperties = DynamicLibrary.open('mqrt.dll')
.lookupFunction<MQGetMachinePropertiesNative, MQGetMachinePropertiesDart>('MQGetMachineProperties');
// lpwcsMachineName : LPCWSTR optional -> Pointer<Utf16>
// pguidMachineId : GUID* optional -> Pointer<Void>
// pQMProps : MQQMPROPS* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MQGetMachineProperties(
lpwcsMachineName: PWideChar; // LPCWSTR optional
pguidMachineId: PGUID; // GUID* optional
pQMProps: Pointer // MQQMPROPS* in/out
): Integer; stdcall;
external 'mqrt.dll' name 'MQGetMachineProperties';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MQGetMachineProperties"
c_MQGetMachineProperties :: CWString -> Ptr () -> Ptr () -> IO Int32
-- lpwcsMachineName : LPCWSTR optional -> CWString
-- pguidMachineId : GUID* optional -> Ptr ()
-- pQMProps : MQQMPROPS* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mqgetmachineproperties =
foreign "MQGetMachineProperties"
((ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* lpwcsMachineName : LPCWSTR optional -> (ptr uint16_t) *)
(* pguidMachineId : GUID* optional -> (ptr void) *)
(* pQMProps : MQQMPROPS* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mqrt (t "mqrt.dll"))
(cffi:use-foreign-library mqrt)
(cffi:defcfun ("MQGetMachineProperties" mqget-machine-properties :convention :stdcall) :int32
(lpwcs-machine-name (:string :encoding :utf-16le)) ; LPCWSTR optional
(pguid-machine-id :pointer) ; GUID* optional
(p-qmprops :pointer)) ; MQQMPROPS* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MQGetMachineProperties = Win32::API::More->new('mqrt',
'int MQGetMachineProperties(LPCWSTR lpwcsMachineName, LPVOID pguidMachineId, LPVOID pQMProps)');
# my $ret = $MQGetMachineProperties->Call($lpwcsMachineName, $pguidMachineId, $pQMProps);
# lpwcsMachineName : LPCWSTR optional -> LPCWSTR
# pguidMachineId : GUID* optional -> LPVOID
# pQMProps : MQQMPROPS* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型