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

MQGetMachineProperties

関数
指定コンピュータのMSMQプロパティを取得する。
DLLmqrt.dll呼出規約winapi

シグネチャ

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

HRESULT MQGetMachineProperties(
    LPCWSTR lpwcsMachineName,   // optional
    const GUID* pguidMachineId,   // optional
    MQQMPROPS* pQMProps
);

パラメーター

名前方向
lpwcsMachineNameLPCWSTRinoptional
pguidMachineIdGUID*inoptional
pQMPropsMQQMPROPS*inout

戻り値の型: 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // HRESULT
function 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)。