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

MQCreateQueue

関数
メッセージキューを新規作成する。
DLLmqrt.dll呼出規約winapi

シグネチャ

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

HRESULT MQCreateQueue(
    PSECURITY_DESCRIPTOR pSecurityDescriptor,   // optional
    MQQUEUEPROPS* pQueueProps,
    LPWSTR lpwcsFormatName,   // optional
    DWORD* lpdwFormatNameLength
);

パラメーター

名前方向
pSecurityDescriptorPSECURITY_DESCRIPTORinoptional
pQueuePropsMQQUEUEPROPS*inout
lpwcsFormatNameLPWSTRoutoptional
lpdwFormatNameLengthDWORD*inout

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT MQCreateQueue(
    PSECURITY_DESCRIPTOR pSecurityDescriptor,   // optional
    MQQUEUEPROPS* pQueueProps,
    LPWSTR lpwcsFormatName,   // optional
    DWORD* lpdwFormatNameLength
);
[DllImport("mqrt.dll", ExactSpelling = true)]
static extern int MQCreateQueue(
    IntPtr pSecurityDescriptor,   // PSECURITY_DESCRIPTOR optional
    IntPtr pQueueProps,   // MQQUEUEPROPS* in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpwcsFormatName,   // LPWSTR optional, out
    ref uint lpdwFormatNameLength   // DWORD* in/out
);
<DllImport("mqrt.dll", ExactSpelling:=True)>
Public Shared Function MQCreateQueue(
    pSecurityDescriptor As IntPtr,   ' PSECURITY_DESCRIPTOR optional
    pQueueProps As IntPtr,   ' MQQUEUEPROPS* in/out
    <MarshalAs(UnmanagedType.LPWStr)> lpwcsFormatName As System.Text.StringBuilder,   ' LPWSTR optional, out
    ByRef lpdwFormatNameLength As UInteger   ' DWORD* in/out
) As Integer
End Function
' pSecurityDescriptor : PSECURITY_DESCRIPTOR optional
' pQueueProps : MQQUEUEPROPS* in/out
' lpwcsFormatName : LPWSTR optional, out
' lpdwFormatNameLength : DWORD* in/out
Declare PtrSafe Function MQCreateQueue Lib "mqrt" ( _
    ByVal pSecurityDescriptor As LongPtr, _
    ByVal pQueueProps As LongPtr, _
    ByVal lpwcsFormatName As LongPtr, _
    ByRef lpdwFormatNameLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MQCreateQueue = ctypes.windll.mqrt.MQCreateQueue
MQCreateQueue.restype = ctypes.c_int
MQCreateQueue.argtypes = [
    wintypes.HANDLE,  # pSecurityDescriptor : PSECURITY_DESCRIPTOR optional
    ctypes.c_void_p,  # pQueueProps : MQQUEUEPROPS* in/out
    wintypes.LPWSTR,  # lpwcsFormatName : LPWSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # lpdwFormatNameLength : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mqrt = windows.NewLazySystemDLL("mqrt.dll")
	procMQCreateQueue = mqrt.NewProc("MQCreateQueue")
)

// pSecurityDescriptor (PSECURITY_DESCRIPTOR optional), pQueueProps (MQQUEUEPROPS* in/out), lpwcsFormatName (LPWSTR optional, out), lpdwFormatNameLength (DWORD* in/out)
r1, _, err := procMQCreateQueue.Call(
	uintptr(pSecurityDescriptor),
	uintptr(pQueueProps),
	uintptr(lpwcsFormatName),
	uintptr(lpdwFormatNameLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function MQCreateQueue(
  pSecurityDescriptor: THandle;   // PSECURITY_DESCRIPTOR optional
  pQueueProps: Pointer;   // MQQUEUEPROPS* in/out
  lpwcsFormatName: PWideChar;   // LPWSTR optional, out
  lpdwFormatNameLength: Pointer   // DWORD* in/out
): Integer; stdcall;
  external 'mqrt.dll' name 'MQCreateQueue';
result := DllCall("mqrt\MQCreateQueue"
    , "Ptr", pSecurityDescriptor   ; PSECURITY_DESCRIPTOR optional
    , "Ptr", pQueueProps   ; MQQUEUEPROPS* in/out
    , "Ptr", lpwcsFormatName   ; LPWSTR optional, out
    , "Ptr", lpdwFormatNameLength   ; DWORD* in/out
    , "Int")   ; return: HRESULT
●MQCreateQueue(pSecurityDescriptor, pQueueProps, lpwcsFormatName, lpdwFormatNameLength) = DLL("mqrt.dll", "int MQCreateQueue(void*, void*, char*, void*)")
# 呼び出し: MQCreateQueue(pSecurityDescriptor, pQueueProps, lpwcsFormatName, lpdwFormatNameLength)
# pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> "void*"
# pQueueProps : MQQUEUEPROPS* in/out -> "void*"
# lpwcsFormatName : LPWSTR optional, out -> "char*"
# lpdwFormatNameLength : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。