ホーム › System.MessageQueuing › MQSetQueueSecurity
MQSetQueueSecurity
関数キューのセキュリティ記述子を設定する。
シグネチャ
// mqrt.dll
#include <windows.h>
HRESULT MQSetQueueSecurity(
LPCWSTR lpwcsFormatName,
OBJECT_SECURITY_INFORMATION SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpwcsFormatName | LPCWSTR | in | セキュリティを設定する対象キューのフォーマット名(ワイド文字列)を指定する。 |
| SecurityInformation | OBJECT_SECURITY_INFORMATION | in | 設定するセキュリティ情報の種別を示すOBJECT_SECURITY_INFORMATIONフラグを指定する。 |
| pSecurityDescriptor | PSECURITY_DESCRIPTOR | inoptional | 設定するセキュリティ記述子へのポインタを指定する。 |
戻り値の型: 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 // HRESULTfunction 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)。const std = @import("std");
extern "mqrt" fn MQSetQueueSecurity(
lpwcsFormatName: [*c]const u16, // LPCWSTR
SecurityInformation: u32, // OBJECT_SECURITY_INFORMATION
pSecurityDescriptor: ?*anyopaque // PSECURITY_DESCRIPTOR optional
) callconv(std.os.windows.WINAPI) i32;proc MQSetQueueSecurity(
lpwcsFormatName: WideCString, # LPCWSTR
SecurityInformation: uint32, # OBJECT_SECURITY_INFORMATION
pSecurityDescriptor: pointer # PSECURITY_DESCRIPTOR optional
): int32 {.importc: "MQSetQueueSecurity", stdcall, dynlib: "mqrt.dll".}pragma(lib, "mqrt");
extern(Windows)
int MQSetQueueSecurity(
const(wchar)* lpwcsFormatName, // LPCWSTR
uint SecurityInformation, // OBJECT_SECURITY_INFORMATION
void* pSecurityDescriptor // PSECURITY_DESCRIPTOR optional
);ccall((:MQSetQueueSecurity, "mqrt.dll"), stdcall, Int32,
(Cwstring, UInt32, Ptr{Cvoid}),
lpwcsFormatName, SecurityInformation, pSecurityDescriptor)
# lpwcsFormatName : LPCWSTR -> Cwstring
# SecurityInformation : OBJECT_SECURITY_INFORMATION -> UInt32
# pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MQSetQueueSecurity(
const uint16_t* lpwcsFormatName,
uint32_t SecurityInformation,
void* pSecurityDescriptor);
]]
local mqrt = ffi.load("mqrt")
-- mqrt.MQSetQueueSecurity(lpwcsFormatName, SecurityInformation, pSecurityDescriptor)
-- lpwcsFormatName : LPCWSTR
-- SecurityInformation : OBJECT_SECURITY_INFORMATION
-- pSecurityDescriptor : PSECURITY_DESCRIPTOR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('mqrt.dll');
const MQSetQueueSecurity = lib.func('__stdcall', 'MQSetQueueSecurity', 'int32_t', ['str16', 'uint32_t', 'void *']);
// MQSetQueueSecurity(lpwcsFormatName, SecurityInformation, pSecurityDescriptor)
// lpwcsFormatName : LPCWSTR -> 'str16'
// SecurityInformation : OBJECT_SECURITY_INFORMATION -> 'uint32_t'
// pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("mqrt.dll", {
MQSetQueueSecurity: { parameters: ["buffer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.MQSetQueueSecurity(lpwcsFormatName, SecurityInformation, pSecurityDescriptor)
// lpwcsFormatName : LPCWSTR -> "buffer"
// SecurityInformation : OBJECT_SECURITY_INFORMATION -> "u32"
// pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MQSetQueueSecurity(
const uint16_t* lpwcsFormatName,
uint32_t SecurityInformation,
void* pSecurityDescriptor);
C, "mqrt.dll");
// $ffi->MQSetQueueSecurity(lpwcsFormatName, SecurityInformation, pSecurityDescriptor);
// lpwcsFormatName : LPCWSTR
// SecurityInformation : OBJECT_SECURITY_INFORMATION
// pSecurityDescriptor : PSECURITY_DESCRIPTOR optional
// 構造体/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 MQSetQueueSecurity(
WString lpwcsFormatName, // LPCWSTR
int SecurityInformation, // OBJECT_SECURITY_INFORMATION
Pointer pSecurityDescriptor // PSECURITY_DESCRIPTOR optional
);
}@[Link("mqrt")]
lib Libmqrt
fun MQSetQueueSecurity = MQSetQueueSecurity(
lpwcsFormatName : UInt16*, # LPCWSTR
SecurityInformation : UInt32, # OBJECT_SECURITY_INFORMATION
pSecurityDescriptor : Void* # PSECURITY_DESCRIPTOR optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MQSetQueueSecurityNative = Int32 Function(Pointer<Utf16>, Uint32, Pointer<Void>);
typedef MQSetQueueSecurityDart = int Function(Pointer<Utf16>, int, Pointer<Void>);
final MQSetQueueSecurity = DynamicLibrary.open('mqrt.dll')
.lookupFunction<MQSetQueueSecurityNative, MQSetQueueSecurityDart>('MQSetQueueSecurity');
// lpwcsFormatName : LPCWSTR -> Pointer<Utf16>
// SecurityInformation : OBJECT_SECURITY_INFORMATION -> Uint32
// pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MQSetQueueSecurity(
lpwcsFormatName: PWideChar; // LPCWSTR
SecurityInformation: DWORD; // OBJECT_SECURITY_INFORMATION
pSecurityDescriptor: THandle // PSECURITY_DESCRIPTOR optional
): Integer; stdcall;
external 'mqrt.dll' name 'MQSetQueueSecurity';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MQSetQueueSecurity"
c_MQSetQueueSecurity :: CWString -> Word32 -> Ptr () -> IO Int32
-- lpwcsFormatName : LPCWSTR -> CWString
-- SecurityInformation : OBJECT_SECURITY_INFORMATION -> Word32
-- pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mqsetqueuesecurity =
foreign "MQSetQueueSecurity"
((ptr uint16_t) @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* lpwcsFormatName : LPCWSTR -> (ptr uint16_t) *)
(* SecurityInformation : OBJECT_SECURITY_INFORMATION -> uint32_t *)
(* pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mqrt (t "mqrt.dll"))
(cffi:use-foreign-library mqrt)
(cffi:defcfun ("MQSetQueueSecurity" mqset-queue-security :convention :stdcall) :int32
(lpwcs-format-name (:string :encoding :utf-16le)) ; LPCWSTR
(security-information :uint32) ; OBJECT_SECURITY_INFORMATION
(p-security-descriptor :pointer)) ; PSECURITY_DESCRIPTOR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MQSetQueueSecurity = Win32::API::More->new('mqrt',
'int MQSetQueueSecurity(LPCWSTR lpwcsFormatName, DWORD SecurityInformation, HANDLE pSecurityDescriptor)');
# my $ret = $MQSetQueueSecurity->Call($lpwcsFormatName, $SecurityInformation, $pSecurityDescriptor);
# lpwcsFormatName : LPCWSTR -> LPCWSTR
# SecurityInformation : OBJECT_SECURITY_INFORMATION -> DWORD
# pSecurityDescriptor : PSECURITY_DESCRIPTOR optional -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。