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

RpcMgmtInqDefaultProtectLevel

関数
認証サービスの既定の保護レベルを取得する。
DLLRPCRT4.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

RPC_STATUS RpcMgmtInqDefaultProtectLevel(
    DWORD AuthnSvc,
    DWORD* AuthnLevel
);

パラメーター

名前方向
AuthnSvcDWORDin
AuthnLevelDWORD*out

戻り値の型: RPC_STATUS

各言語での呼び出し定義

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

RPC_STATUS RpcMgmtInqDefaultProtectLevel(
    DWORD AuthnSvc,
    DWORD* AuthnLevel
);
[DllImport("RPCRT4.dll", ExactSpelling = true)]
static extern int RpcMgmtInqDefaultProtectLevel(
    uint AuthnSvc,   // DWORD
    out uint AuthnLevel   // DWORD* out
);
<DllImport("RPCRT4.dll", ExactSpelling:=True)>
Public Shared Function RpcMgmtInqDefaultProtectLevel(
    AuthnSvc As UInteger,   ' DWORD
    <Out> ByRef AuthnLevel As UInteger   ' DWORD* out
) As Integer
End Function
' AuthnSvc : DWORD
' AuthnLevel : DWORD* out
Declare PtrSafe Function RpcMgmtInqDefaultProtectLevel Lib "rpcrt4" ( _
    ByVal AuthnSvc As Long, _
    ByRef AuthnLevel As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RpcMgmtInqDefaultProtectLevel = ctypes.windll.rpcrt4.RpcMgmtInqDefaultProtectLevel
RpcMgmtInqDefaultProtectLevel.restype = ctypes.c_int
RpcMgmtInqDefaultProtectLevel.argtypes = [
    wintypes.DWORD,  # AuthnSvc : DWORD
    ctypes.POINTER(wintypes.DWORD),  # AuthnLevel : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procRpcMgmtInqDefaultProtectLevel = rpcrt4.NewProc("RpcMgmtInqDefaultProtectLevel")
)

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