ホーム › Networking.Ldap › ldap_explode_dnW
ldap_explode_dnW
関数DN文字列を構成要素の配列に分解する(Unicode版)。
シグネチャ
// WLDAP32.dll (Unicode / -W)
#include <windows.h>
LPWSTR* ldap_explode_dnW(
LPCWSTR dn,
DWORD notypes
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| dn | LPCWSTR | in | 分解対象のDN文字列(Unicode)。各構成要素(RDN)に分割して配列で返す。 |
| notypes | DWORD | in | 0以外なら属性型を除き値のみを返す。0なら型を含めたRDN全体を返す。 |
戻り値の型: LPWSTR*
各言語での呼び出し定義
// WLDAP32.dll (Unicode / -W)
#include <windows.h>
LPWSTR* ldap_explode_dnW(
LPCWSTR dn,
DWORD notypes
);[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ldap_explode_dnW(
[MarshalAs(UnmanagedType.LPWStr)] string dn, // LPCWSTR
uint notypes // DWORD
);<DllImport("WLDAP32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_explode_dnW(
<MarshalAs(UnmanagedType.LPWStr)> dn As String, ' LPCWSTR
notypes As UInteger ' DWORD
) As IntPtr
End Function' dn : LPCWSTR
' notypes : DWORD
Declare PtrSafe Function ldap_explode_dnW Lib "wldap32" ( _
ByVal dn As LongPtr, _
ByVal notypes As Long) As LongPtr
' 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_explode_dnW = ctypes.cdll.wldap32.ldap_explode_dnW
ldap_explode_dnW.restype = wintypes.LPWSTR
ldap_explode_dnW.argtypes = [
wintypes.LPCWSTR, # dn : LPCWSTR
wintypes.DWORD, # notypes : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WLDAP32.dll')
ldap_explode_dnW = Fiddle::Function.new(
lib['ldap_explode_dnW'],
[
Fiddle::TYPE_VOIDP, # dn : LPCWSTR
-Fiddle::TYPE_INT, # notypes : DWORD
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "wldap32")]
extern "C" {
fn ldap_explode_dnW(
dn: *const u16, // LPCWSTR
notypes: u32 // DWORD
) -> *mut *mut u16;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ldap_explode_dnW([MarshalAs(UnmanagedType.LPWStr)] string dn, uint notypes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ldap_explode_dnW' -Namespace Win32 -PassThru
# $api::ldap_explode_dnW(dn, notypes)#uselib "WLDAP32.dll"
#func global ldap_explode_dnW "ldap_explode_dnW" wptr, wptr
; ldap_explode_dnW dn, notypes ; 戻り値は stat
; dn : LPCWSTR -> "wptr"
; notypes : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WLDAP32.dll"
#cfunc global ldap_explode_dnW "ldap_explode_dnW" wstr, int
; res = ldap_explode_dnW(dn, notypes)
; dn : LPCWSTR -> "wstr"
; notypes : DWORD -> "int"; LPWSTR* ldap_explode_dnW(LPCWSTR dn, DWORD notypes)
#uselib "WLDAP32.dll"
#cfunc global ldap_explode_dnW "ldap_explode_dnW" wstr, int
; res = ldap_explode_dnW(dn, notypes)
; dn : LPCWSTR -> "wstr"
; notypes : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
procldap_explode_dnW = wldap32.NewProc("ldap_explode_dnW")
)
// dn (LPCWSTR), notypes (DWORD)
r1, _, err := procldap_explode_dnW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(dn))),
uintptr(notypes),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // LPWSTR*function ldap_explode_dnW(
dn: PWideChar; // LPCWSTR
notypes: DWORD // DWORD
): PWideChar; cdecl;
external 'WLDAP32.dll' name 'ldap_explode_dnW';result := DllCall("WLDAP32\ldap_explode_dnW"
, "WStr", dn ; LPCWSTR
, "UInt", notypes ; DWORD
, "Cdecl Ptr") ; return: LPWSTR*●ldap_explode_dnW(dn, notypes) = DLL("WLDAP32.dll", "void* ldap_explode_dnW(char*, dword)")
# 呼び出し: ldap_explode_dnW(dn, notypes)
# dn : LPCWSTR -> "char*"
# notypes : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "wldap32" fn ldap_explode_dnW(
dn: [*c]const u16, // LPCWSTR
notypes: u32 // DWORD
) callconv(.c) [*c][*c]u16;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc ldap_explode_dnW(
dn: WideCString, # LPCWSTR
notypes: uint32 # DWORD
): ptr WideCString {.importc: "ldap_explode_dnW", cdecl, dynlib: "WLDAP32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "wldap32");
extern(C)
wchar** ldap_explode_dnW(
const(wchar)* dn, // LPCWSTR
uint notypes // DWORD
);ccall((:ldap_explode_dnW, "WLDAP32.dll"), Ptr{Ptr{UInt16}},
(Cwstring, UInt32),
dn, notypes)
# dn : LPCWSTR -> Cwstring
# notypes : DWORD -> UInt32
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint16_t** ldap_explode_dnW(
const uint16_t* dn,
uint32_t notypes);
]]
local wldap32 = ffi.load("wldap32")
-- wldap32.ldap_explode_dnW(dn, notypes)
-- dn : LPCWSTR
-- notypes : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('WLDAP32.dll');
const ldap_explode_dnW = lib.func('__cdecl', 'ldap_explode_dnW', 'void *', ['str16', 'uint32_t']);
// ldap_explode_dnW(dn, notypes)
// dn : LPCWSTR -> 'str16'
// notypes : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WLDAP32.dll", {
ldap_explode_dnW: { parameters: ["buffer", "u32"], result: "pointer" },
});
// lib.symbols.ldap_explode_dnW(dn, notypes)
// dn : LPCWSTR -> "buffer"
// notypes : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint16_t** ldap_explode_dnW(
const uint16_t* dn,
uint32_t notypes);
C, "WLDAP32.dll");
// $ffi->ldap_explode_dnW(dn, notypes);
// dn : LPCWSTR
// notypes : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Wldap32 extends Library {
Wldap32 INSTANCE = Native.load("wldap32", Wldap32.class, W32APIOptions.UNICODE_OPTIONS);
Pointer ldap_explode_dnW(
WString dn, // LPCWSTR
int notypes // DWORD
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("wldap32")]
lib LibWLDAP32
fun ldap_explode_dnW = ldap_explode_dnW(
dn : UInt16*, # LPCWSTR
notypes : UInt32 # DWORD
) : UInt16**
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ldap_explode_dnWNative = Pointer<Pointer<Utf16>> Function(Pointer<Utf16>, Uint32);
typedef ldap_explode_dnWDart = Pointer<Pointer<Utf16>> Function(Pointer<Utf16>, int);
final ldap_explode_dnW = DynamicLibrary.open('WLDAP32.dll')
.lookupFunction<ldap_explode_dnWNative, ldap_explode_dnWDart>('ldap_explode_dnW');
// dn : LPCWSTR -> Pointer<Utf16>
// notypes : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ldap_explode_dnW(
dn: PWideChar; // LPCWSTR
notypes: DWORD // DWORD
): PWideChar; cdecl;
external 'WLDAP32.dll' name 'ldap_explode_dnW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ldap_explode_dnW"
c_ldap_explode_dnW :: CWString -> Word32 -> IO (Ptr CWString)
-- dn : LPCWSTR -> CWString
-- notypes : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ldap_explode_dnw =
foreign "ldap_explode_dnW"
((ptr uint16_t) @-> uint32_t @-> returning (ptr (ptr uint16_t)))
(* dn : LPCWSTR -> (ptr uint16_t) *)
(* notypes : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wldap32 (t "WLDAP32.dll"))
(cffi:use-foreign-library wldap32)
(cffi:defcfun ("ldap_explode_dnW" ldap-explode-dn-w :convention :cdecl) :pointer
(dn (:string :encoding :utf-16le)) ; LPCWSTR
(notypes :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ldap_explode_dnW = Win32::API::More->new('WLDAP32',
'LPWSTR ldap_explode_dnW(LPCWSTR dn, DWORD notypes)');
# my $ret = $ldap_explode_dnW->Call($dn, $notypes);
# dn : LPCWSTR -> LPCWSTR
# notypes : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f ldap_explode_dnA (ANSI版) — DN文字列を構成要素の配列に分解する(ANSI版)。