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

ldap_ufn2dnW

関数
利用者向け表記の名前をDN形式に変換する(Unicode版)。
DLLWLDAP32.dll文字セットUnicode (-W)呼出規約cdecl対応OSWindows Vista 以降

シグネチャ

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

DWORD ldap_ufn2dnW(
    LPCWSTR ufn,
    LPWSTR* pDn
);

パラメーター

名前方向
ufnLPCWSTRin
pDnLPWSTR*out

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD ldap_ufn2dnW(
    LPCWSTR ufn,
    LPWSTR* pDn
);
[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern uint ldap_ufn2dnW(
    [MarshalAs(UnmanagedType.LPWStr)] string ufn,   // LPCWSTR
    IntPtr pDn   // LPWSTR* out
);
<DllImport("WLDAP32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_ufn2dnW(
    <MarshalAs(UnmanagedType.LPWStr)> ufn As String,   ' LPCWSTR
    pDn As IntPtr   ' LPWSTR* out
) As UInteger
End Function
' ufn : LPCWSTR
' pDn : LPWSTR* out
Declare PtrSafe Function ldap_ufn2dnW Lib "wldap32" ( _
    ByVal ufn As LongPtr, _
    ByVal pDn 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

ldap_ufn2dnW = ctypes.cdll.wldap32.ldap_ufn2dnW
ldap_ufn2dnW.restype = wintypes.DWORD
ldap_ufn2dnW.argtypes = [
    wintypes.LPCWSTR,  # ufn : LPCWSTR
    ctypes.c_void_p,  # pDn : LPWSTR* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
	procldap_ufn2dnW = wldap32.NewProc("ldap_ufn2dnW")
)

// ufn (LPCWSTR), pDn (LPWSTR* out)
r1, _, err := procldap_ufn2dnW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ufn))),
	uintptr(pDn),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function ldap_ufn2dnW(
  ufn: PWideChar;   // LPCWSTR
  pDn: PPWideChar   // LPWSTR* out
): DWORD; cdecl;
  external 'WLDAP32.dll' name 'ldap_ufn2dnW';
result := DllCall("WLDAP32\ldap_ufn2dnW"
    , "WStr", ufn   ; LPCWSTR
    , "Ptr", pDn   ; LPWSTR* out
    , "Cdecl UInt")   ; return: DWORD
●ldap_ufn2dnW(ufn, pDn) = DLL("WLDAP32.dll", "dword ldap_ufn2dnW(char*, void*)")
# 呼び出し: ldap_ufn2dnW(ufn, pDn)
# ufn : LPCWSTR -> "char*"
# pDn : LPWSTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。