Win32 API 日本語リファレンス
ホームNetworking.ActiveDirectory › DsCrackSpn2W

DsCrackSpn2W

関数
長さ指定付きでSPNを構成要素へ分解する(Unicode版)。
DLLDSPARSE.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

// DSPARSE.dll  (Unicode / -W)
#include <windows.h>

DWORD DsCrackSpn2W(
    LPCWSTR pszSpn,
    DWORD cSpn,
    DWORD* pcServiceClass,   // optional
    LPWSTR ServiceClass,   // optional
    DWORD* pcServiceName,   // optional
    LPWSTR ServiceName,   // optional
    DWORD* pcInstanceName,   // optional
    LPWSTR InstanceName,   // optional
    WORD* pInstancePort   // optional
);

パラメーター

名前方向
pszSpnLPCWSTRin
cSpnDWORDin
pcServiceClassDWORD*inoutoptional
ServiceClassLPWSTRoutoptional
pcServiceNameDWORD*inoutoptional
ServiceNameLPWSTRoutoptional
pcInstanceNameDWORD*inoutoptional
InstanceNameLPWSTRoutoptional
pInstancePortWORD*outoptional

戻り値の型: DWORD

各言語での呼び出し定義

// DSPARSE.dll  (Unicode / -W)
#include <windows.h>

DWORD DsCrackSpn2W(
    LPCWSTR pszSpn,
    DWORD cSpn,
    DWORD* pcServiceClass,   // optional
    LPWSTR ServiceClass,   // optional
    DWORD* pcServiceName,   // optional
    LPWSTR ServiceName,   // optional
    DWORD* pcInstanceName,   // optional
    LPWSTR InstanceName,   // optional
    WORD* pInstancePort   // optional
);
[DllImport("DSPARSE.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint DsCrackSpn2W(
    [MarshalAs(UnmanagedType.LPWStr)] string pszSpn,   // LPCWSTR
    uint cSpn,   // DWORD
    IntPtr pcServiceClass,   // DWORD* optional, in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder ServiceClass,   // LPWSTR optional, out
    IntPtr pcServiceName,   // DWORD* optional, in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder ServiceName,   // LPWSTR optional, out
    IntPtr pcInstanceName,   // DWORD* optional, in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder InstanceName,   // LPWSTR optional, out
    IntPtr pInstancePort   // WORD* optional, out
);
<DllImport("DSPARSE.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function DsCrackSpn2W(
    <MarshalAs(UnmanagedType.LPWStr)> pszSpn As String,   ' LPCWSTR
    cSpn As UInteger,   ' DWORD
    pcServiceClass As IntPtr,   ' DWORD* optional, in/out
    <MarshalAs(UnmanagedType.LPWStr)> ServiceClass As System.Text.StringBuilder,   ' LPWSTR optional, out
    pcServiceName As IntPtr,   ' DWORD* optional, in/out
    <MarshalAs(UnmanagedType.LPWStr)> ServiceName As System.Text.StringBuilder,   ' LPWSTR optional, out
    pcInstanceName As IntPtr,   ' DWORD* optional, in/out
    <MarshalAs(UnmanagedType.LPWStr)> InstanceName As System.Text.StringBuilder,   ' LPWSTR optional, out
    pInstancePort As IntPtr   ' WORD* optional, out
) As UInteger
End Function
' pszSpn : LPCWSTR
' cSpn : DWORD
' pcServiceClass : DWORD* optional, in/out
' ServiceClass : LPWSTR optional, out
' pcServiceName : DWORD* optional, in/out
' ServiceName : LPWSTR optional, out
' pcInstanceName : DWORD* optional, in/out
' InstanceName : LPWSTR optional, out
' pInstancePort : WORD* optional, out
Declare PtrSafe Function DsCrackSpn2W Lib "dsparse" ( _
    ByVal pszSpn As LongPtr, _
    ByVal cSpn As Long, _
    ByVal pcServiceClass As LongPtr, _
    ByVal ServiceClass As LongPtr, _
    ByVal pcServiceName As LongPtr, _
    ByVal ServiceName As LongPtr, _
    ByVal pcInstanceName As LongPtr, _
    ByVal InstanceName As LongPtr, _
    ByVal pInstancePort 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

DsCrackSpn2W = ctypes.windll.dsparse.DsCrackSpn2W
DsCrackSpn2W.restype = wintypes.DWORD
DsCrackSpn2W.argtypes = [
    wintypes.LPCWSTR,  # pszSpn : LPCWSTR
    wintypes.DWORD,  # cSpn : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pcServiceClass : DWORD* optional, in/out
    wintypes.LPWSTR,  # ServiceClass : LPWSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcServiceName : DWORD* optional, in/out
    wintypes.LPWSTR,  # ServiceName : LPWSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcInstanceName : DWORD* optional, in/out
    wintypes.LPWSTR,  # InstanceName : LPWSTR optional, out
    ctypes.POINTER(ctypes.c_ushort),  # pInstancePort : WORD* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('DSPARSE.dll')
DsCrackSpn2W = Fiddle::Function.new(
  lib['DsCrackSpn2W'],
  [
    Fiddle::TYPE_VOIDP,  # pszSpn : LPCWSTR
    -Fiddle::TYPE_INT,  # cSpn : DWORD
    Fiddle::TYPE_VOIDP,  # pcServiceClass : DWORD* optional, in/out
    Fiddle::TYPE_VOIDP,  # ServiceClass : LPWSTR optional, out
    Fiddle::TYPE_VOIDP,  # pcServiceName : DWORD* optional, in/out
    Fiddle::TYPE_VOIDP,  # ServiceName : LPWSTR optional, out
    Fiddle::TYPE_VOIDP,  # pcInstanceName : DWORD* optional, in/out
    Fiddle::TYPE_VOIDP,  # InstanceName : LPWSTR optional, out
    Fiddle::TYPE_VOIDP,  # pInstancePort : WORD* optional, out
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "dsparse")]
extern "system" {
    fn DsCrackSpn2W(
        pszSpn: *const u16,  // LPCWSTR
        cSpn: u32,  // DWORD
        pcServiceClass: *mut u32,  // DWORD* optional, in/out
        ServiceClass: *mut u16,  // LPWSTR optional, out
        pcServiceName: *mut u32,  // DWORD* optional, in/out
        ServiceName: *mut u16,  // LPWSTR optional, out
        pcInstanceName: *mut u32,  // DWORD* optional, in/out
        InstanceName: *mut u16,  // LPWSTR optional, out
        pInstancePort: *mut u16  // WORD* optional, out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("DSPARSE.dll", CharSet = CharSet.Unicode)]
public static extern uint DsCrackSpn2W([MarshalAs(UnmanagedType.LPWStr)] string pszSpn, uint cSpn, IntPtr pcServiceClass, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder ServiceClass, IntPtr pcServiceName, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder ServiceName, IntPtr pcInstanceName, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder InstanceName, IntPtr pInstancePort);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DSPARSE_DsCrackSpn2W' -Namespace Win32 -PassThru
# $api::DsCrackSpn2W(pszSpn, cSpn, pcServiceClass, ServiceClass, pcServiceName, ServiceName, pcInstanceName, InstanceName, pInstancePort)
#uselib "DSPARSE.dll"
#func global DsCrackSpn2W "DsCrackSpn2W" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; DsCrackSpn2W pszSpn, cSpn, varptr(pcServiceClass), varptr(ServiceClass), varptr(pcServiceName), varptr(ServiceName), varptr(pcInstanceName), varptr(InstanceName), varptr(pInstancePort)   ; 戻り値は stat
; pszSpn : LPCWSTR -> "wptr"
; cSpn : DWORD -> "wptr"
; pcServiceClass : DWORD* optional, in/out -> "wptr"
; ServiceClass : LPWSTR optional, out -> "wptr"
; pcServiceName : DWORD* optional, in/out -> "wptr"
; ServiceName : LPWSTR optional, out -> "wptr"
; pcInstanceName : DWORD* optional, in/out -> "wptr"
; InstanceName : LPWSTR optional, out -> "wptr"
; pInstancePort : WORD* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "DSPARSE.dll"
#cfunc global DsCrackSpn2W "DsCrackSpn2W" wstr, int, var, var, var, var, var, var, var
; res = DsCrackSpn2W(pszSpn, cSpn, pcServiceClass, ServiceClass, pcServiceName, ServiceName, pcInstanceName, InstanceName, pInstancePort)
; pszSpn : LPCWSTR -> "wstr"
; cSpn : DWORD -> "int"
; pcServiceClass : DWORD* optional, in/out -> "var"
; ServiceClass : LPWSTR optional, out -> "var"
; pcServiceName : DWORD* optional, in/out -> "var"
; ServiceName : LPWSTR optional, out -> "var"
; pcInstanceName : DWORD* optional, in/out -> "var"
; InstanceName : LPWSTR optional, out -> "var"
; pInstancePort : WORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD DsCrackSpn2W(LPCWSTR pszSpn, DWORD cSpn, DWORD* pcServiceClass, LPWSTR ServiceClass, DWORD* pcServiceName, LPWSTR ServiceName, DWORD* pcInstanceName, LPWSTR InstanceName, WORD* pInstancePort)
#uselib "DSPARSE.dll"
#cfunc global DsCrackSpn2W "DsCrackSpn2W" wstr, int, var, var, var, var, var, var, var
; res = DsCrackSpn2W(pszSpn, cSpn, pcServiceClass, ServiceClass, pcServiceName, ServiceName, pcInstanceName, InstanceName, pInstancePort)
; pszSpn : LPCWSTR -> "wstr"
; cSpn : DWORD -> "int"
; pcServiceClass : DWORD* optional, in/out -> "var"
; ServiceClass : LPWSTR optional, out -> "var"
; pcServiceName : DWORD* optional, in/out -> "var"
; ServiceName : LPWSTR optional, out -> "var"
; pcInstanceName : DWORD* optional, in/out -> "var"
; InstanceName : LPWSTR optional, out -> "var"
; pInstancePort : WORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dsparse = windows.NewLazySystemDLL("DSPARSE.dll")
	procDsCrackSpn2W = dsparse.NewProc("DsCrackSpn2W")
)

// pszSpn (LPCWSTR), cSpn (DWORD), pcServiceClass (DWORD* optional, in/out), ServiceClass (LPWSTR optional, out), pcServiceName (DWORD* optional, in/out), ServiceName (LPWSTR optional, out), pcInstanceName (DWORD* optional, in/out), InstanceName (LPWSTR optional, out), pInstancePort (WORD* optional, out)
r1, _, err := procDsCrackSpn2W.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszSpn))),
	uintptr(cSpn),
	uintptr(pcServiceClass),
	uintptr(ServiceClass),
	uintptr(pcServiceName),
	uintptr(ServiceName),
	uintptr(pcInstanceName),
	uintptr(InstanceName),
	uintptr(pInstancePort),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function DsCrackSpn2W(
  pszSpn: PWideChar;   // LPCWSTR
  cSpn: DWORD;   // DWORD
  pcServiceClass: Pointer;   // DWORD* optional, in/out
  ServiceClass: PWideChar;   // LPWSTR optional, out
  pcServiceName: Pointer;   // DWORD* optional, in/out
  ServiceName: PWideChar;   // LPWSTR optional, out
  pcInstanceName: Pointer;   // DWORD* optional, in/out
  InstanceName: PWideChar;   // LPWSTR optional, out
  pInstancePort: Pointer   // WORD* optional, out
): DWORD; stdcall;
  external 'DSPARSE.dll' name 'DsCrackSpn2W';
result := DllCall("DSPARSE\DsCrackSpn2W"
    , "WStr", pszSpn   ; LPCWSTR
    , "UInt", cSpn   ; DWORD
    , "Ptr", pcServiceClass   ; DWORD* optional, in/out
    , "Ptr", ServiceClass   ; LPWSTR optional, out
    , "Ptr", pcServiceName   ; DWORD* optional, in/out
    , "Ptr", ServiceName   ; LPWSTR optional, out
    , "Ptr", pcInstanceName   ; DWORD* optional, in/out
    , "Ptr", InstanceName   ; LPWSTR optional, out
    , "Ptr", pInstancePort   ; WORD* optional, out
    , "UInt")   ; return: DWORD
●DsCrackSpn2W(pszSpn, cSpn, pcServiceClass, ServiceClass, pcServiceName, ServiceName, pcInstanceName, InstanceName, pInstancePort) = DLL("DSPARSE.dll", "dword DsCrackSpn2W(char*, dword, void*, char*, void*, char*, void*, char*, void*)")
# 呼び出し: DsCrackSpn2W(pszSpn, cSpn, pcServiceClass, ServiceClass, pcServiceName, ServiceName, pcInstanceName, InstanceName, pInstancePort)
# pszSpn : LPCWSTR -> "char*"
# cSpn : DWORD -> "dword"
# pcServiceClass : DWORD* optional, in/out -> "void*"
# ServiceClass : LPWSTR optional, out -> "char*"
# pcServiceName : DWORD* optional, in/out -> "void*"
# ServiceName : LPWSTR optional, out -> "char*"
# pcInstanceName : DWORD* optional, in/out -> "void*"
# InstanceName : LPWSTR optional, out -> "char*"
# pInstancePort : WORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。