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