ホーム › System.Rpc › RpcServerRegisterAuthInfoW
RpcServerRegisterAuthInfoW
関数RPCサーバーに認証サービスとプリンシパル名を登録する(Unicode版)。
シグネチャ
// RPCRT4.dll (Unicode / -W)
#include <windows.h>
RPC_STATUS RpcServerRegisterAuthInfoW(
LPWSTR ServerPrincName, // optional
DWORD AuthnSvc,
RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFn, // optional
void* Arg // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ServerPrincName | LPWSTR | inoptional |
| AuthnSvc | DWORD | in |
| GetKeyFn | RPC_AUTH_KEY_RETRIEVAL_FN | inoptional |
| Arg | void* | inoptional |
戻り値の型: RPC_STATUS
各言語での呼び出し定義
// RPCRT4.dll (Unicode / -W)
#include <windows.h>
RPC_STATUS RpcServerRegisterAuthInfoW(
LPWSTR ServerPrincName, // optional
DWORD AuthnSvc,
RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFn, // optional
void* Arg // optional
);[DllImport("RPCRT4.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int RpcServerRegisterAuthInfoW(
[MarshalAs(UnmanagedType.LPWStr)] string ServerPrincName, // LPWSTR optional
uint AuthnSvc, // DWORD
IntPtr GetKeyFn, // RPC_AUTH_KEY_RETRIEVAL_FN optional
IntPtr Arg // void* optional
);<DllImport("RPCRT4.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RpcServerRegisterAuthInfoW(
<MarshalAs(UnmanagedType.LPWStr)> ServerPrincName As String, ' LPWSTR optional
AuthnSvc As UInteger, ' DWORD
GetKeyFn As IntPtr, ' RPC_AUTH_KEY_RETRIEVAL_FN optional
Arg As IntPtr ' void* optional
) As Integer
End Function' ServerPrincName : LPWSTR optional
' AuthnSvc : DWORD
' GetKeyFn : RPC_AUTH_KEY_RETRIEVAL_FN optional
' Arg : void* optional
Declare PtrSafe Function RpcServerRegisterAuthInfoW Lib "rpcrt4" ( _
ByVal ServerPrincName As LongPtr, _
ByVal AuthnSvc As Long, _
ByVal GetKeyFn As LongPtr, _
ByVal Arg As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RpcServerRegisterAuthInfoW = ctypes.windll.rpcrt4.RpcServerRegisterAuthInfoW
RpcServerRegisterAuthInfoW.restype = ctypes.c_int
RpcServerRegisterAuthInfoW.argtypes = [
wintypes.LPCWSTR, # ServerPrincName : LPWSTR optional
wintypes.DWORD, # AuthnSvc : DWORD
ctypes.c_void_p, # GetKeyFn : RPC_AUTH_KEY_RETRIEVAL_FN optional
ctypes.POINTER(None), # Arg : void* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RPCRT4.dll')
RpcServerRegisterAuthInfoW = Fiddle::Function.new(
lib['RpcServerRegisterAuthInfoW'],
[
Fiddle::TYPE_VOIDP, # ServerPrincName : LPWSTR optional
-Fiddle::TYPE_INT, # AuthnSvc : DWORD
Fiddle::TYPE_VOIDP, # GetKeyFn : RPC_AUTH_KEY_RETRIEVAL_FN optional
Fiddle::TYPE_VOIDP, # Arg : void* optional
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "rpcrt4")]
extern "system" {
fn RpcServerRegisterAuthInfoW(
ServerPrincName: *mut u16, // LPWSTR optional
AuthnSvc: u32, // DWORD
GetKeyFn: *const core::ffi::c_void, // RPC_AUTH_KEY_RETRIEVAL_FN optional
Arg: *mut () // void* optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RPCRT4.dll", CharSet = CharSet.Unicode)]
public static extern int RpcServerRegisterAuthInfoW([MarshalAs(UnmanagedType.LPWStr)] string ServerPrincName, uint AuthnSvc, IntPtr GetKeyFn, IntPtr Arg);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_RpcServerRegisterAuthInfoW' -Namespace Win32 -PassThru
# $api::RpcServerRegisterAuthInfoW(ServerPrincName, AuthnSvc, GetKeyFn, Arg)#uselib "RPCRT4.dll"
#func global RpcServerRegisterAuthInfoW "RpcServerRegisterAuthInfoW" wptr, wptr, wptr, wptr
; RpcServerRegisterAuthInfoW ServerPrincName, AuthnSvc, GetKeyFn, Arg ; 戻り値は stat
; ServerPrincName : LPWSTR optional -> "wptr"
; AuthnSvc : DWORD -> "wptr"
; GetKeyFn : RPC_AUTH_KEY_RETRIEVAL_FN optional -> "wptr"
; Arg : void* optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "RPCRT4.dll"
#cfunc global RpcServerRegisterAuthInfoW "RpcServerRegisterAuthInfoW" wstr, int, sptr, sptr
; res = RpcServerRegisterAuthInfoW(ServerPrincName, AuthnSvc, GetKeyFn, Arg)
; ServerPrincName : LPWSTR optional -> "wstr"
; AuthnSvc : DWORD -> "int"
; GetKeyFn : RPC_AUTH_KEY_RETRIEVAL_FN optional -> "sptr"
; Arg : void* optional -> "sptr"; RPC_STATUS RpcServerRegisterAuthInfoW(LPWSTR ServerPrincName, DWORD AuthnSvc, RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFn, void* Arg)
#uselib "RPCRT4.dll"
#cfunc global RpcServerRegisterAuthInfoW "RpcServerRegisterAuthInfoW" wstr, int, intptr, intptr
; res = RpcServerRegisterAuthInfoW(ServerPrincName, AuthnSvc, GetKeyFn, Arg)
; ServerPrincName : LPWSTR optional -> "wstr"
; AuthnSvc : DWORD -> "int"
; GetKeyFn : RPC_AUTH_KEY_RETRIEVAL_FN optional -> "intptr"
; Arg : void* optional -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
procRpcServerRegisterAuthInfoW = rpcrt4.NewProc("RpcServerRegisterAuthInfoW")
)
// ServerPrincName (LPWSTR optional), AuthnSvc (DWORD), GetKeyFn (RPC_AUTH_KEY_RETRIEVAL_FN optional), Arg (void* optional)
r1, _, err := procRpcServerRegisterAuthInfoW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerPrincName))),
uintptr(AuthnSvc),
uintptr(GetKeyFn),
uintptr(Arg),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // RPC_STATUSfunction RpcServerRegisterAuthInfoW(
ServerPrincName: PWideChar; // LPWSTR optional
AuthnSvc: DWORD; // DWORD
GetKeyFn: Pointer; // RPC_AUTH_KEY_RETRIEVAL_FN optional
Arg: Pointer // void* optional
): Integer; stdcall;
external 'RPCRT4.dll' name 'RpcServerRegisterAuthInfoW';result := DllCall("RPCRT4\RpcServerRegisterAuthInfoW"
, "WStr", ServerPrincName ; LPWSTR optional
, "UInt", AuthnSvc ; DWORD
, "Ptr", GetKeyFn ; RPC_AUTH_KEY_RETRIEVAL_FN optional
, "Ptr", Arg ; void* optional
, "Int") ; return: RPC_STATUS●RpcServerRegisterAuthInfoW(ServerPrincName, AuthnSvc, GetKeyFn, Arg) = DLL("RPCRT4.dll", "int RpcServerRegisterAuthInfoW(char*, dword, void*, void*)")
# 呼び出し: RpcServerRegisterAuthInfoW(ServerPrincName, AuthnSvc, GetKeyFn, Arg)
# ServerPrincName : LPWSTR optional -> "char*"
# AuthnSvc : DWORD -> "dword"
# GetKeyFn : RPC_AUTH_KEY_RETRIEVAL_FN optional -> "void*"
# Arg : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。