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

ldap_first_attributeW

関数
エントリから最初の属性名を取得する(Unicode版)。
DLLWLDAP32.dll文字セットUnicode (-W)呼出規約cdecl対応OSWindows Vista 以降

シグネチャ

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

LPWSTR ldap_first_attributeW(
    LDAP* ld,
    LDAPMessage* entry,
    BerElement** ptr
);

パラメーター

名前方向説明
ldLDAP*inout対象のLDAPセッションハンドル。検索を実行した接続を指す。
entryLDAPMessage*inout属性を列挙する対象のエントリ。ldap_first_entry等で取得したものを渡す。
ptrBerElement**inout列挙状態を保持するBerElementポインタを受け取る出力先。後続列挙とber_freeに使う。

戻り値の型: LPWSTR

各言語での呼び出し定義

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

LPWSTR ldap_first_attributeW(
    LDAP* ld,
    LDAPMessage* entry,
    BerElement** ptr
);
[DllImport("WLDAP32.dll", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ldap_first_attributeW(
    IntPtr ld,   // LDAP* in/out
    IntPtr entry,   // LDAPMessage* in/out
    IntPtr ptr   // BerElement** in/out
);
<DllImport("WLDAP32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ldap_first_attributeW(
    ld As IntPtr,   ' LDAP* in/out
    entry As IntPtr,   ' LDAPMessage* in/out
    ptr As IntPtr   ' BerElement** in/out
) As IntPtr
End Function
' ld : LDAP* in/out
' entry : LDAPMessage* in/out
' ptr : BerElement** in/out
Declare PtrSafe Function ldap_first_attributeW Lib "wldap32" ( _
    ByVal ld As LongPtr, _
    ByVal entry As LongPtr, _
    ByVal ptr As LongPtr) 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_first_attributeW = ctypes.cdll.wldap32.ldap_first_attributeW
ldap_first_attributeW.restype = wintypes.LPWSTR
ldap_first_attributeW.argtypes = [
    ctypes.c_void_p,  # ld : LDAP* in/out
    ctypes.c_void_p,  # entry : LDAPMessage* in/out
    ctypes.c_void_p,  # ptr : BerElement** in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WLDAP32.dll')
ldap_first_attributeW = Fiddle::Function.new(
  lib['ldap_first_attributeW'],
  [
    Fiddle::TYPE_VOIDP,  # ld : LDAP* in/out
    Fiddle::TYPE_VOIDP,  # entry : LDAPMessage* in/out
    Fiddle::TYPE_VOIDP,  # ptr : BerElement** in/out
  ],
  Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "wldap32")]
extern "C" {
    fn ldap_first_attributeW(
        ld: *mut LDAP,  // LDAP* in/out
        entry: *mut LDAPMessage,  // LDAPMessage* in/out
        ptr: *mut *mut BerElement  // BerElement** in/out
    ) -> *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_first_attributeW(IntPtr ld, IntPtr entry, IntPtr ptr);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WLDAP32_ldap_first_attributeW' -Namespace Win32 -PassThru
# $api::ldap_first_attributeW(ld, entry, ptr)
#uselib "WLDAP32.dll"
#func global ldap_first_attributeW "ldap_first_attributeW" wptr, wptr, wptr
; ldap_first_attributeW varptr(ld), varptr(entry), varptr(ptr)   ; 戻り値は stat
; ld : LDAP* in/out -> "wptr"
; entry : LDAPMessage* in/out -> "wptr"
; ptr : BerElement** in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WLDAP32.dll"
#cfunc global ldap_first_attributeW "ldap_first_attributeW" var, var, var
; res = ldap_first_attributeW(ld, entry, ptr)
; ld : LDAP* in/out -> "var"
; entry : LDAPMessage* in/out -> "var"
; ptr : BerElement** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; LPWSTR ldap_first_attributeW(LDAP* ld, LDAPMessage* entry, BerElement** ptr)
#uselib "WLDAP32.dll"
#cfunc global ldap_first_attributeW "ldap_first_attributeW" var, var, var
; res = ldap_first_attributeW(ld, entry, ptr)
; ld : LDAP* in/out -> "var"
; entry : LDAPMessage* in/out -> "var"
; ptr : BerElement** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wldap32 = windows.NewLazySystemDLL("WLDAP32.dll")
	procldap_first_attributeW = wldap32.NewProc("ldap_first_attributeW")
)

// ld (LDAP* in/out), entry (LDAPMessage* in/out), ptr (BerElement** in/out)
r1, _, err := procldap_first_attributeW.Call(
	uintptr(ld),
	uintptr(entry),
	uintptr(ptr),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // LPWSTR
function ldap_first_attributeW(
  ld: Pointer;   // LDAP* in/out
  entry: Pointer;   // LDAPMessage* in/out
  ptr: Pointer   // BerElement** in/out
): PWideChar; cdecl;
  external 'WLDAP32.dll' name 'ldap_first_attributeW';
result := DllCall("WLDAP32\ldap_first_attributeW"
    , "Ptr", ld   ; LDAP* in/out
    , "Ptr", entry   ; LDAPMessage* in/out
    , "Ptr", ptr   ; BerElement** in/out
    , "Cdecl Ptr")   ; return: LPWSTR
●ldap_first_attributeW(ld, entry, ptr) = DLL("WLDAP32.dll", "char* ldap_first_attributeW(void*, void*, void*)")
# 呼び出し: ldap_first_attributeW(ld, entry, ptr)
# ld : LDAP* in/out -> "void*"
# entry : LDAPMessage* in/out -> "void*"
# ptr : BerElement** in/out -> "void*"
# なでしこ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_first_attributeW(
    ld: [*c]LDAP, // LDAP* in/out
    entry: [*c]LDAPMessage, // LDAPMessage* in/out
    ptr: [*c][*c]BerElement // BerElement** in/out
) callconv(.c) [*c]const u16;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc ldap_first_attributeW(
    ld: ptr LDAP,  # LDAP* in/out
    entry: ptr LDAPMessage,  # LDAPMessage* in/out
    `ptr`: ptr BerElement  # BerElement** in/out
): WideCString {.importc: "ldap_first_attributeW", cdecl, dynlib: "WLDAP32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "wldap32");
extern(C)
const(wchar)* ldap_first_attributeW(
    LDAP* ld,   // LDAP* in/out
    LDAPMessage* entry,   // LDAPMessage* in/out
    BerElement** ptr   // BerElement** in/out
);
ccall((:ldap_first_attributeW, "WLDAP32.dll"), Cwstring,
      (Ptr{LDAP}, Ptr{LDAPMessage}, Ptr{BerElement}),
      ld, entry, ptr)
# ld : LDAP* in/out -> Ptr{LDAP}
# entry : LDAPMessage* in/out -> Ptr{LDAPMessage}
# ptr : BerElement** in/out -> Ptr{BerElement}
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
const uint16_t* ldap_first_attributeW(
    void* ld,
    void* entry,
    void* ptr);
]]
local wldap32 = ffi.load("wldap32")
-- wldap32.ldap_first_attributeW(ld, entry, ptr)
-- ld : LDAP* in/out
-- entry : LDAPMessage* in/out
-- ptr : BerElement** in/out
-- 構造体/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_first_attributeW = lib.func('__cdecl', 'ldap_first_attributeW', 'void *', ['void *', 'void *', 'void *']);
// ldap_first_attributeW(ld, entry, ptr)
// ld : LDAP* in/out -> 'void *'
// entry : LDAPMessage* in/out -> 'void *'
// ptr : BerElement** in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WLDAP32.dll", {
  ldap_first_attributeW: { parameters: ["pointer", "pointer", "pointer"], result: "pointer" },
});
// lib.symbols.ldap_first_attributeW(ld, entry, ptr)
// ld : LDAP* in/out -> "pointer"
// entry : LDAPMessage* in/out -> "pointer"
// ptr : BerElement** in/out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
const uint16_t* ldap_first_attributeW(
    void* ld,
    void* entry,
    void* ptr);
C, "WLDAP32.dll");
// $ffi->ldap_first_attributeW(ld, entry, ptr);
// ld : LDAP* in/out
// entry : LDAPMessage* in/out
// ptr : BerElement** in/out
// 構造体/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_first_attributeW(
        Pointer ld,   // LDAP* in/out
        Pointer entry,   // LDAPMessage* in/out
        Pointer ptr   // BerElement** in/out
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("wldap32")]
lib LibWLDAP32
  fun ldap_first_attributeW = ldap_first_attributeW(
    ld : LDAP*,   # LDAP* in/out
    entry : LDAPMessage*,   # LDAPMessage* in/out
    ptr : BerElement**   # BerElement** in/out
  ) : UInt16*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ldap_first_attributeWNative = Pointer<Utf16> Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef ldap_first_attributeWDart = Pointer<Utf16> Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
final ldap_first_attributeW = DynamicLibrary.open('WLDAP32.dll')
    .lookupFunction<ldap_first_attributeWNative, ldap_first_attributeWDart>('ldap_first_attributeW');
// ld : LDAP* in/out -> Pointer<Void>
// entry : LDAPMessage* in/out -> Pointer<Void>
// ptr : BerElement** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ldap_first_attributeW(
  ld: Pointer;   // LDAP* in/out
  entry: Pointer;   // LDAPMessage* in/out
  ptr: Pointer   // BerElement** in/out
): PWideChar; cdecl;
  external 'WLDAP32.dll' name 'ldap_first_attributeW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "ldap_first_attributeW"
  c_ldap_first_attributeW :: Ptr () -> Ptr () -> Ptr () -> IO CWString
-- ld : LDAP* in/out -> Ptr ()
-- entry : LDAPMessage* in/out -> Ptr ()
-- ptr : BerElement** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let ldap_first_attributew =
  foreign "ldap_first_attributeW"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> returning (ptr uint16_t))
(* ld : LDAP* in/out -> (ptr void) *)
(* entry : LDAPMessage* in/out -> (ptr void) *)
(* ptr : BerElement** in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wldap32 (t "WLDAP32.dll"))
(cffi:use-foreign-library wldap32)

(cffi:defcfun ("ldap_first_attributeW" ldap-first-attribute-w :convention :cdecl) (:string :encoding :utf-16le)
  (ld :pointer)   ; LDAP* in/out
  (entry :pointer)   ; LDAPMessage* in/out
  (ptr :pointer))   ; BerElement** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ldap_first_attributeW = Win32::API::More->new('WLDAP32',
    'LPWSTR ldap_first_attributeW(LPVOID ld, LPVOID entry, LPVOID ptr)');
# my $ret = $ldap_first_attributeW->Call($ld, $entry, $ptr);
# ld : LDAP* in/out -> LPVOID
# entry : LDAPMessage* in/out -> LPVOID
# ptr : BerElement** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い
使用する型