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

MQGetPrivateComputerInformation

関数
コンピュータのプライベートMSMQ情報を取得する。
DLLmqrt.dll呼出規約winapi

シグネチャ

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

HRESULT MQGetPrivateComputerInformation(
    LPCWSTR lpwcsComputerName,   // optional
    MQPRIVATEPROPS* pPrivateProps
);

パラメーター

名前方向説明
lpwcsComputerNameLPCWSTRinoptional情報を取得する対象コンピューター名(ワイド文字列)。NULL可でローカルとなる。
pPrivatePropsMQPRIVATEPROPS*inout取得するプライベートコンピュータープロパティを受け渡すMQPRIVATEPROPS構造体へのポインタを指定する。

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

MQGetPrivateComputerInformation = ctypes.windll.mqrt.MQGetPrivateComputerInformation
MQGetPrivateComputerInformation.restype = ctypes.c_int
MQGetPrivateComputerInformation.argtypes = [
    wintypes.LPCWSTR,  # lpwcsComputerName : LPCWSTR optional
    ctypes.c_void_p,  # pPrivateProps : MQPRIVATEPROPS* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mqrt.dll')
MQGetPrivateComputerInformation = Fiddle::Function.new(
  lib['MQGetPrivateComputerInformation'],
  [
    Fiddle::TYPE_VOIDP,  # lpwcsComputerName : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # pPrivateProps : MQPRIVATEPROPS* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "mqrt")]
extern "system" {
    fn MQGetPrivateComputerInformation(
        lpwcsComputerName: *const u16,  // LPCWSTR optional
        pPrivateProps: *mut MQPRIVATEPROPS  // MQPRIVATEPROPS* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("mqrt.dll")]
public static extern int MQGetPrivateComputerInformation([MarshalAs(UnmanagedType.LPWStr)] string lpwcsComputerName, IntPtr pPrivateProps);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mqrt_MQGetPrivateComputerInformation' -Namespace Win32 -PassThru
# $api::MQGetPrivateComputerInformation(lpwcsComputerName, pPrivateProps)
#uselib "mqrt.dll"
#func global MQGetPrivateComputerInformation "MQGetPrivateComputerInformation" sptr, sptr
; MQGetPrivateComputerInformation lpwcsComputerName, varptr(pPrivateProps)   ; 戻り値は stat
; lpwcsComputerName : LPCWSTR optional -> "sptr"
; pPrivateProps : MQPRIVATEPROPS* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "mqrt.dll"
#cfunc global MQGetPrivateComputerInformation "MQGetPrivateComputerInformation" wstr, var
; res = MQGetPrivateComputerInformation(lpwcsComputerName, pPrivateProps)
; lpwcsComputerName : LPCWSTR optional -> "wstr"
; pPrivateProps : MQPRIVATEPROPS* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT MQGetPrivateComputerInformation(LPCWSTR lpwcsComputerName, MQPRIVATEPROPS* pPrivateProps)
#uselib "mqrt.dll"
#cfunc global MQGetPrivateComputerInformation "MQGetPrivateComputerInformation" wstr, var
; res = MQGetPrivateComputerInformation(lpwcsComputerName, pPrivateProps)
; lpwcsComputerName : LPCWSTR optional -> "wstr"
; pPrivateProps : MQPRIVATEPROPS* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mqrt = windows.NewLazySystemDLL("mqrt.dll")
	procMQGetPrivateComputerInformation = mqrt.NewProc("MQGetPrivateComputerInformation")
)

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

extern "mqrt" fn MQGetPrivateComputerInformation(
    lpwcsComputerName: [*c]const u16, // LPCWSTR optional
    pPrivateProps: [*c]MQPRIVATEPROPS // MQPRIVATEPROPS* in/out
) callconv(std.os.windows.WINAPI) i32;
proc MQGetPrivateComputerInformation(
    lpwcsComputerName: WideCString,  # LPCWSTR optional
    pPrivateProps: ptr MQPRIVATEPROPS  # MQPRIVATEPROPS* in/out
): int32 {.importc: "MQGetPrivateComputerInformation", stdcall, dynlib: "mqrt.dll".}
pragma(lib, "mqrt");
extern(Windows)
int MQGetPrivateComputerInformation(
    const(wchar)* lpwcsComputerName,   // LPCWSTR optional
    MQPRIVATEPROPS* pPrivateProps   // MQPRIVATEPROPS* in/out
);
ccall((:MQGetPrivateComputerInformation, "mqrt.dll"), stdcall, Int32,
      (Cwstring, Ptr{MQPRIVATEPROPS}),
      lpwcsComputerName, pPrivateProps)
# lpwcsComputerName : LPCWSTR optional -> Cwstring
# pPrivateProps : MQPRIVATEPROPS* in/out -> Ptr{MQPRIVATEPROPS}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t MQGetPrivateComputerInformation(
    const uint16_t* lpwcsComputerName,
    void* pPrivateProps);
]]
local mqrt = ffi.load("mqrt")
-- mqrt.MQGetPrivateComputerInformation(lpwcsComputerName, pPrivateProps)
-- lpwcsComputerName : LPCWSTR optional
-- pPrivateProps : MQPRIVATEPROPS* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('mqrt.dll');
const MQGetPrivateComputerInformation = lib.func('__stdcall', 'MQGetPrivateComputerInformation', 'int32_t', ['str16', 'void *']);
// MQGetPrivateComputerInformation(lpwcsComputerName, pPrivateProps)
// lpwcsComputerName : LPCWSTR optional -> 'str16'
// pPrivateProps : MQPRIVATEPROPS* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("mqrt.dll", {
  MQGetPrivateComputerInformation: { parameters: ["buffer", "pointer"], result: "i32" },
});
// lib.symbols.MQGetPrivateComputerInformation(lpwcsComputerName, pPrivateProps)
// lpwcsComputerName : LPCWSTR optional -> "buffer"
// pPrivateProps : MQPRIVATEPROPS* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t MQGetPrivateComputerInformation(
    const uint16_t* lpwcsComputerName,
    void* pPrivateProps);
C, "mqrt.dll");
// $ffi->MQGetPrivateComputerInformation(lpwcsComputerName, pPrivateProps);
// lpwcsComputerName : LPCWSTR optional
// pPrivateProps : MQPRIVATEPROPS* 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 MQGetPrivateComputerInformation(
        WString lpwcsComputerName,   // LPCWSTR optional
        Pointer pPrivateProps   // MQPRIVATEPROPS* in/out
    );
}
@[Link("mqrt")]
lib Libmqrt
  fun MQGetPrivateComputerInformation = MQGetPrivateComputerInformation(
    lpwcsComputerName : UInt16*,   # LPCWSTR optional
    pPrivateProps : MQPRIVATEPROPS*   # MQPRIVATEPROPS* 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 MQGetPrivateComputerInformationNative = Int32 Function(Pointer<Utf16>, Pointer<Void>);
typedef MQGetPrivateComputerInformationDart = int Function(Pointer<Utf16>, Pointer<Void>);
final MQGetPrivateComputerInformation = DynamicLibrary.open('mqrt.dll')
    .lookupFunction<MQGetPrivateComputerInformationNative, MQGetPrivateComputerInformationDart>('MQGetPrivateComputerInformation');
// lpwcsComputerName : LPCWSTR optional -> Pointer<Utf16>
// pPrivateProps : MQPRIVATEPROPS* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MQGetPrivateComputerInformation(
  lpwcsComputerName: PWideChar;   // LPCWSTR optional
  pPrivateProps: Pointer   // MQPRIVATEPROPS* in/out
): Integer; stdcall;
  external 'mqrt.dll' name 'MQGetPrivateComputerInformation';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MQGetPrivateComputerInformation"
  c_MQGetPrivateComputerInformation :: CWString -> Ptr () -> IO Int32
-- lpwcsComputerName : LPCWSTR optional -> CWString
-- pPrivateProps : MQPRIVATEPROPS* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mqgetprivatecomputerinformation =
  foreign "MQGetPrivateComputerInformation"
    ((ptr uint16_t) @-> (ptr void) @-> returning int32_t)
(* lpwcsComputerName : LPCWSTR optional -> (ptr uint16_t) *)
(* pPrivateProps : MQPRIVATEPROPS* 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 ("MQGetPrivateComputerInformation" mqget-private-computer-information :convention :stdcall) :int32
  (lpwcs-computer-name (:string :encoding :utf-16le))   ; LPCWSTR optional
  (p-private-props :pointer))   ; MQPRIVATEPROPS* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MQGetPrivateComputerInformation = Win32::API::More->new('mqrt',
    'int MQGetPrivateComputerInformation(LPCWSTR lpwcsComputerName, LPVOID pPrivateProps)');
# my $ret = $MQGetPrivateComputerInformation->Call($lpwcsComputerName, $pPrivateProps);
# lpwcsComputerName : LPCWSTR optional -> LPCWSTR
# pPrivateProps : MQPRIVATEPROPS* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型