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

MQSetQueueSecurity

関数
キューのセキュリティ記述子を設定する。
DLLmqrt.dll呼出規約winapi

シグネチャ

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

HRESULT MQSetQueueSecurity(
    LPCWSTR lpwcsFormatName,
    OBJECT_SECURITY_INFORMATION SecurityInformation,
    PSECURITY_DESCRIPTOR pSecurityDescriptor   // optional
);

パラメーター

名前方向
lpwcsFormatNameLPCWSTRin
SecurityInformationOBJECT_SECURITY_INFORMATIONin
pSecurityDescriptorPSECURITY_DESCRIPTORinoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

MQSetQueueSecurity = ctypes.windll.mqrt.MQSetQueueSecurity
MQSetQueueSecurity.restype = ctypes.c_int
MQSetQueueSecurity.argtypes = [
    wintypes.LPCWSTR,  # lpwcsFormatName : LPCWSTR
    wintypes.DWORD,  # SecurityInformation : OBJECT_SECURITY_INFORMATION
    wintypes.HANDLE,  # pSecurityDescriptor : PSECURITY_DESCRIPTOR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mqrt.dll')
MQSetQueueSecurity = Fiddle::Function.new(
  lib['MQSetQueueSecurity'],
  [
    Fiddle::TYPE_VOIDP,  # lpwcsFormatName : LPCWSTR
    -Fiddle::TYPE_INT,  # SecurityInformation : OBJECT_SECURITY_INFORMATION
    Fiddle::TYPE_VOIDP,  # pSecurityDescriptor : PSECURITY_DESCRIPTOR optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "mqrt")]
extern "system" {
    fn MQSetQueueSecurity(
        lpwcsFormatName: *const u16,  // LPCWSTR
        SecurityInformation: u32,  // OBJECT_SECURITY_INFORMATION
        pSecurityDescriptor: *mut core::ffi::c_void  // PSECURITY_DESCRIPTOR optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("mqrt.dll")]
public static extern int MQSetQueueSecurity([MarshalAs(UnmanagedType.LPWStr)] string lpwcsFormatName, uint SecurityInformation, IntPtr pSecurityDescriptor);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mqrt_MQSetQueueSecurity' -Namespace Win32 -PassThru
# $api::MQSetQueueSecurity(lpwcsFormatName, SecurityInformation, pSecurityDescriptor)
#uselib "mqrt.dll"
#func global MQSetQueueSecurity "MQSetQueueSecurity" sptr, sptr, sptr
; MQSetQueueSecurity lpwcsFormatName, SecurityInformation, pSecurityDescriptor   ; 戻り値は stat
; lpwcsFormatName : LPCWSTR -> "sptr"
; SecurityInformation : OBJECT_SECURITY_INFORMATION -> "sptr"
; pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "mqrt.dll"
#cfunc global MQSetQueueSecurity "MQSetQueueSecurity" wstr, int, sptr
; res = MQSetQueueSecurity(lpwcsFormatName, SecurityInformation, pSecurityDescriptor)
; lpwcsFormatName : LPCWSTR -> "wstr"
; SecurityInformation : OBJECT_SECURITY_INFORMATION -> "int"
; pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> "sptr"
; HRESULT MQSetQueueSecurity(LPCWSTR lpwcsFormatName, OBJECT_SECURITY_INFORMATION SecurityInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor)
#uselib "mqrt.dll"
#cfunc global MQSetQueueSecurity "MQSetQueueSecurity" wstr, int, intptr
; res = MQSetQueueSecurity(lpwcsFormatName, SecurityInformation, pSecurityDescriptor)
; lpwcsFormatName : LPCWSTR -> "wstr"
; SecurityInformation : OBJECT_SECURITY_INFORMATION -> "int"
; pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mqrt = windows.NewLazySystemDLL("mqrt.dll")
	procMQSetQueueSecurity = mqrt.NewProc("MQSetQueueSecurity")
)

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