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

MQGetSecurityContext

関数
証明書からセキュリティコンテキストを取得する。
DLLmqrt.dll呼出規約winapi

シグネチャ

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

HRESULT MQGetSecurityContext(
    void* lpCertBuffer,   // optional
    DWORD dwCertBufferLength,
    HANDLE* phSecurityContext
);

パラメーター

名前方向
lpCertBuffervoid*inoptional
dwCertBufferLengthDWORDin
phSecurityContextHANDLE*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT MQGetSecurityContext(
    void* lpCertBuffer,   // optional
    DWORD dwCertBufferLength,
    HANDLE* phSecurityContext
);
[DllImport("mqrt.dll", ExactSpelling = true)]
static extern int MQGetSecurityContext(
    IntPtr lpCertBuffer,   // void* optional
    uint dwCertBufferLength,   // DWORD
    IntPtr phSecurityContext   // HANDLE* out
);
<DllImport("mqrt.dll", ExactSpelling:=True)>
Public Shared Function MQGetSecurityContext(
    lpCertBuffer As IntPtr,   ' void* optional
    dwCertBufferLength As UInteger,   ' DWORD
    phSecurityContext As IntPtr   ' HANDLE* out
) As Integer
End Function
' lpCertBuffer : void* optional
' dwCertBufferLength : DWORD
' phSecurityContext : HANDLE* out
Declare PtrSafe Function MQGetSecurityContext Lib "mqrt" ( _
    ByVal lpCertBuffer As LongPtr, _
    ByVal dwCertBufferLength As Long, _
    ByVal phSecurityContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MQGetSecurityContext = ctypes.windll.mqrt.MQGetSecurityContext
MQGetSecurityContext.restype = ctypes.c_int
MQGetSecurityContext.argtypes = [
    ctypes.POINTER(None),  # lpCertBuffer : void* optional
    wintypes.DWORD,  # dwCertBufferLength : DWORD
    ctypes.c_void_p,  # phSecurityContext : HANDLE* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mqrt = windows.NewLazySystemDLL("mqrt.dll")
	procMQGetSecurityContext = mqrt.NewProc("MQGetSecurityContext")
)

// lpCertBuffer (void* optional), dwCertBufferLength (DWORD), phSecurityContext (HANDLE* out)
r1, _, err := procMQGetSecurityContext.Call(
	uintptr(lpCertBuffer),
	uintptr(dwCertBufferLength),
	uintptr(phSecurityContext),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function MQGetSecurityContext(
  lpCertBuffer: Pointer;   // void* optional
  dwCertBufferLength: DWORD;   // DWORD
  phSecurityContext: Pointer   // HANDLE* out
): Integer; stdcall;
  external 'mqrt.dll' name 'MQGetSecurityContext';
result := DllCall("mqrt\MQGetSecurityContext"
    , "Ptr", lpCertBuffer   ; void* optional
    , "UInt", dwCertBufferLength   ; DWORD
    , "Ptr", phSecurityContext   ; HANDLE* out
    , "Int")   ; return: HRESULT
●MQGetSecurityContext(lpCertBuffer, dwCertBufferLength, phSecurityContext) = DLL("mqrt.dll", "int MQGetSecurityContext(void*, dword, void*)")
# 呼び出し: MQGetSecurityContext(lpCertBuffer, dwCertBufferLength, phSecurityContext)
# lpCertBuffer : void* optional -> "void*"
# dwCertBufferLength : DWORD -> "dword"
# phSecurityContext : HANDLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。