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

DsGetRdnW

関数
識別名の先頭RDNからキーと値を抽出する(Unicode版)。
DLLDSPARSE.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// DSPARSE.dll
#include <windows.h>

DWORD DsGetRdnW(
    LPWSTR* ppDN,
    DWORD* pcDN,
    LPWSTR* ppKey,
    DWORD* pcKey,
    LPWSTR* ppVal,
    DWORD* pcVal
);

パラメーター

名前方向説明
ppDNLPWSTR*inout入出力でDN文字列の現在位置を指すポインタのアドレス。先頭RDN消費後に更新される。
pcDNDWORD*inout入出力で残りDNの文字数を受け渡すDWORDへのポインタ。
ppKeyLPWSTR*out先頭RDNのキー部分先頭を受け取るポインタのアドレス。
pcKeyDWORD*outキー部分の文字数を受け取るDWORDへのポインタ。
ppValLPWSTR*out先頭RDNの値部分先頭を受け取るポインタのアドレス。
pcValDWORD*out値部分の文字数を受け取るDWORDへのポインタ。

戻り値の型: DWORD

各言語での呼び出し定義

// DSPARSE.dll
#include <windows.h>

DWORD DsGetRdnW(
    LPWSTR* ppDN,
    DWORD* pcDN,
    LPWSTR* ppKey,
    DWORD* pcKey,
    LPWSTR* ppVal,
    DWORD* pcVal
);
[DllImport("DSPARSE.dll", ExactSpelling = true)]
static extern uint DsGetRdnW(
    IntPtr ppDN,   // LPWSTR* in/out
    ref uint pcDN,   // DWORD* in/out
    IntPtr ppKey,   // LPWSTR* out
    out uint pcKey,   // DWORD* out
    IntPtr ppVal,   // LPWSTR* out
    out uint pcVal   // DWORD* out
);
<DllImport("DSPARSE.dll", ExactSpelling:=True)>
Public Shared Function DsGetRdnW(
    ppDN As IntPtr,   ' LPWSTR* in/out
    ByRef pcDN As UInteger,   ' DWORD* in/out
    ppKey As IntPtr,   ' LPWSTR* out
    <Out> ByRef pcKey As UInteger,   ' DWORD* out
    ppVal As IntPtr,   ' LPWSTR* out
    <Out> ByRef pcVal As UInteger   ' DWORD* out
) As UInteger
End Function
' ppDN : LPWSTR* in/out
' pcDN : DWORD* in/out
' ppKey : LPWSTR* out
' pcKey : DWORD* out
' ppVal : LPWSTR* out
' pcVal : DWORD* out
Declare PtrSafe Function DsGetRdnW Lib "dsparse" ( _
    ByVal ppDN As LongPtr, _
    ByRef pcDN As Long, _
    ByVal ppKey As LongPtr, _
    ByRef pcKey As Long, _
    ByVal ppVal As LongPtr, _
    ByRef pcVal As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DsGetRdnW = ctypes.windll.dsparse.DsGetRdnW
DsGetRdnW.restype = wintypes.DWORD
DsGetRdnW.argtypes = [
    ctypes.c_void_p,  # ppDN : LPWSTR* in/out
    ctypes.POINTER(wintypes.DWORD),  # pcDN : DWORD* in/out
    ctypes.c_void_p,  # ppKey : LPWSTR* out
    ctypes.POINTER(wintypes.DWORD),  # pcKey : DWORD* out
    ctypes.c_void_p,  # ppVal : LPWSTR* out
    ctypes.POINTER(wintypes.DWORD),  # pcVal : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('DSPARSE.dll')
DsGetRdnW = Fiddle::Function.new(
  lib['DsGetRdnW'],
  [
    Fiddle::TYPE_VOIDP,  # ppDN : LPWSTR* in/out
    Fiddle::TYPE_VOIDP,  # pcDN : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # ppKey : LPWSTR* out
    Fiddle::TYPE_VOIDP,  # pcKey : DWORD* out
    Fiddle::TYPE_VOIDP,  # ppVal : LPWSTR* out
    Fiddle::TYPE_VOIDP,  # pcVal : DWORD* out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "dsparse")]
extern "system" {
    fn DsGetRdnW(
        ppDN: *mut *mut u16,  // LPWSTR* in/out
        pcDN: *mut u32,  // DWORD* in/out
        ppKey: *mut *mut u16,  // LPWSTR* out
        pcKey: *mut u32,  // DWORD* out
        ppVal: *mut *mut u16,  // LPWSTR* out
        pcVal: *mut u32  // DWORD* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("DSPARSE.dll")]
public static extern uint DsGetRdnW(IntPtr ppDN, ref uint pcDN, IntPtr ppKey, out uint pcKey, IntPtr ppVal, out uint pcVal);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DSPARSE_DsGetRdnW' -Namespace Win32 -PassThru
# $api::DsGetRdnW(ppDN, pcDN, ppKey, pcKey, ppVal, pcVal)
#uselib "DSPARSE.dll"
#func global DsGetRdnW "DsGetRdnW" sptr, sptr, sptr, sptr, sptr, sptr
; DsGetRdnW varptr(ppDN), varptr(pcDN), varptr(ppKey), varptr(pcKey), varptr(ppVal), varptr(pcVal)   ; 戻り値は stat
; ppDN : LPWSTR* in/out -> "sptr"
; pcDN : DWORD* in/out -> "sptr"
; ppKey : LPWSTR* out -> "sptr"
; pcKey : DWORD* out -> "sptr"
; ppVal : LPWSTR* out -> "sptr"
; pcVal : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "DSPARSE.dll"
#cfunc global DsGetRdnW "DsGetRdnW" var, var, var, var, var, var
; res = DsGetRdnW(ppDN, pcDN, ppKey, pcKey, ppVal, pcVal)
; ppDN : LPWSTR* in/out -> "var"
; pcDN : DWORD* in/out -> "var"
; ppKey : LPWSTR* out -> "var"
; pcKey : DWORD* out -> "var"
; ppVal : LPWSTR* out -> "var"
; pcVal : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD DsGetRdnW(LPWSTR* ppDN, DWORD* pcDN, LPWSTR* ppKey, DWORD* pcKey, LPWSTR* ppVal, DWORD* pcVal)
#uselib "DSPARSE.dll"
#cfunc global DsGetRdnW "DsGetRdnW" var, var, var, var, var, var
; res = DsGetRdnW(ppDN, pcDN, ppKey, pcKey, ppVal, pcVal)
; ppDN : LPWSTR* in/out -> "var"
; pcDN : DWORD* in/out -> "var"
; ppKey : LPWSTR* out -> "var"
; pcKey : DWORD* out -> "var"
; ppVal : LPWSTR* out -> "var"
; pcVal : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dsparse = windows.NewLazySystemDLL("DSPARSE.dll")
	procDsGetRdnW = dsparse.NewProc("DsGetRdnW")
)

// ppDN (LPWSTR* in/out), pcDN (DWORD* in/out), ppKey (LPWSTR* out), pcKey (DWORD* out), ppVal (LPWSTR* out), pcVal (DWORD* out)
r1, _, err := procDsGetRdnW.Call(
	uintptr(ppDN),
	uintptr(pcDN),
	uintptr(ppKey),
	uintptr(pcKey),
	uintptr(ppVal),
	uintptr(pcVal),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function DsGetRdnW(
  ppDN: PPWideChar;   // LPWSTR* in/out
  pcDN: Pointer;   // DWORD* in/out
  ppKey: PPWideChar;   // LPWSTR* out
  pcKey: Pointer;   // DWORD* out
  ppVal: PPWideChar;   // LPWSTR* out
  pcVal: Pointer   // DWORD* out
): DWORD; stdcall;
  external 'DSPARSE.dll' name 'DsGetRdnW';
result := DllCall("DSPARSE\DsGetRdnW"
    , "Ptr", ppDN   ; LPWSTR* in/out
    , "Ptr", pcDN   ; DWORD* in/out
    , "Ptr", ppKey   ; LPWSTR* out
    , "Ptr", pcKey   ; DWORD* out
    , "Ptr", ppVal   ; LPWSTR* out
    , "Ptr", pcVal   ; DWORD* out
    , "UInt")   ; return: DWORD
●DsGetRdnW(ppDN, pcDN, ppKey, pcKey, ppVal, pcVal) = DLL("DSPARSE.dll", "dword DsGetRdnW(void*, void*, void*, void*, void*, void*)")
# 呼び出し: DsGetRdnW(ppDN, pcDN, ppKey, pcKey, ppVal, pcVal)
# ppDN : LPWSTR* in/out -> "void*"
# pcDN : DWORD* in/out -> "void*"
# ppKey : LPWSTR* out -> "void*"
# pcKey : DWORD* out -> "void*"
# ppVal : LPWSTR* out -> "void*"
# pcVal : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "dsparse" fn DsGetRdnW(
    ppDN: [*c][*c]u16, // LPWSTR* in/out
    pcDN: [*c]u32, // DWORD* in/out
    ppKey: [*c][*c]u16, // LPWSTR* out
    pcKey: [*c]u32, // DWORD* out
    ppVal: [*c][*c]u16, // LPWSTR* out
    pcVal: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) u32;
proc DsGetRdnW(
    ppDN: ptr WideCString,  # LPWSTR* in/out
    pcDN: ptr uint32,  # DWORD* in/out
    ppKey: ptr WideCString,  # LPWSTR* out
    pcKey: ptr uint32,  # DWORD* out
    ppVal: ptr WideCString,  # LPWSTR* out
    pcVal: ptr uint32  # DWORD* out
): uint32 {.importc: "DsGetRdnW", stdcall, dynlib: "DSPARSE.dll".}
pragma(lib, "dsparse");
extern(Windows)
uint DsGetRdnW(
    wchar** ppDN,   // LPWSTR* in/out
    uint* pcDN,   // DWORD* in/out
    wchar** ppKey,   // LPWSTR* out
    uint* pcKey,   // DWORD* out
    wchar** ppVal,   // LPWSTR* out
    uint* pcVal   // DWORD* out
);
ccall((:DsGetRdnW, "DSPARSE.dll"), stdcall, UInt32,
      (Ptr{Ptr{UInt16}}, Ptr{UInt32}, Ptr{Ptr{UInt16}}, Ptr{UInt32}, Ptr{Ptr{UInt16}}, Ptr{UInt32}),
      ppDN, pcDN, ppKey, pcKey, ppVal, pcVal)
# ppDN : LPWSTR* in/out -> Ptr{Ptr{UInt16}}
# pcDN : DWORD* in/out -> Ptr{UInt32}
# ppKey : LPWSTR* out -> Ptr{Ptr{UInt16}}
# pcKey : DWORD* out -> Ptr{UInt32}
# ppVal : LPWSTR* out -> Ptr{Ptr{UInt16}}
# pcVal : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t DsGetRdnW(
    uint16_t** ppDN,
    uint32_t* pcDN,
    uint16_t** ppKey,
    uint32_t* pcKey,
    uint16_t** ppVal,
    uint32_t* pcVal);
]]
local dsparse = ffi.load("dsparse")
-- dsparse.DsGetRdnW(ppDN, pcDN, ppKey, pcKey, ppVal, pcVal)
-- ppDN : LPWSTR* in/out
-- pcDN : DWORD* in/out
-- ppKey : LPWSTR* out
-- pcKey : DWORD* out
-- ppVal : LPWSTR* out
-- pcVal : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('DSPARSE.dll');
const DsGetRdnW = lib.func('__stdcall', 'DsGetRdnW', 'uint32_t', ['void *', 'uint32_t *', 'void *', 'uint32_t *', 'void *', 'uint32_t *']);
// DsGetRdnW(ppDN, pcDN, ppKey, pcKey, ppVal, pcVal)
// ppDN : LPWSTR* in/out -> 'void *'
// pcDN : DWORD* in/out -> 'uint32_t *'
// ppKey : LPWSTR* out -> 'void *'
// pcKey : DWORD* out -> 'uint32_t *'
// ppVal : LPWSTR* out -> 'void *'
// pcVal : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("DSPARSE.dll", {
  DsGetRdnW: { parameters: ["pointer", "pointer", "pointer", "pointer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.DsGetRdnW(ppDN, pcDN, ppKey, pcKey, ppVal, pcVal)
// ppDN : LPWSTR* in/out -> "pointer"
// pcDN : DWORD* in/out -> "pointer"
// ppKey : LPWSTR* out -> "pointer"
// pcKey : DWORD* out -> "pointer"
// ppVal : LPWSTR* out -> "pointer"
// pcVal : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t DsGetRdnW(
    uint16_t** ppDN,
    uint32_t* pcDN,
    uint16_t** ppKey,
    uint32_t* pcKey,
    uint16_t** ppVal,
    uint32_t* pcVal);
C, "DSPARSE.dll");
// $ffi->DsGetRdnW(ppDN, pcDN, ppKey, pcKey, ppVal, pcVal);
// ppDN : LPWSTR* in/out
// pcDN : DWORD* in/out
// ppKey : LPWSTR* out
// pcKey : DWORD* out
// ppVal : LPWSTR* out
// pcVal : DWORD* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Dsparse extends StdCallLibrary {
    Dsparse INSTANCE = Native.load("dsparse", Dsparse.class);
    int DsGetRdnW(
        PointerByReference ppDN,   // LPWSTR* in/out
        IntByReference pcDN,   // DWORD* in/out
        PointerByReference ppKey,   // LPWSTR* out
        IntByReference pcKey,   // DWORD* out
        PointerByReference ppVal,   // LPWSTR* out
        IntByReference pcVal   // DWORD* out
    );
}
@[Link("dsparse")]
lib LibDSPARSE
  fun DsGetRdnW = DsGetRdnW(
    ppDN : UInt16**,   # LPWSTR* in/out
    pcDN : UInt32*,   # DWORD* in/out
    ppKey : UInt16**,   # LPWSTR* out
    pcKey : UInt32*,   # DWORD* out
    ppVal : UInt16**,   # LPWSTR* out
    pcVal : UInt32*   # DWORD* out
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef DsGetRdnWNative = Uint32 Function(Pointer<Pointer<Utf16>>, Pointer<Uint32>, Pointer<Pointer<Utf16>>, Pointer<Uint32>, Pointer<Pointer<Utf16>>, Pointer<Uint32>);
typedef DsGetRdnWDart = int Function(Pointer<Pointer<Utf16>>, Pointer<Uint32>, Pointer<Pointer<Utf16>>, Pointer<Uint32>, Pointer<Pointer<Utf16>>, Pointer<Uint32>);
final DsGetRdnW = DynamicLibrary.open('DSPARSE.dll')
    .lookupFunction<DsGetRdnWNative, DsGetRdnWDart>('DsGetRdnW');
// ppDN : LPWSTR* in/out -> Pointer<Pointer<Utf16>>
// pcDN : DWORD* in/out -> Pointer<Uint32>
// ppKey : LPWSTR* out -> Pointer<Pointer<Utf16>>
// pcKey : DWORD* out -> Pointer<Uint32>
// ppVal : LPWSTR* out -> Pointer<Pointer<Utf16>>
// pcVal : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function DsGetRdnW(
  ppDN: PPWideChar;   // LPWSTR* in/out
  pcDN: Pointer;   // DWORD* in/out
  ppKey: PPWideChar;   // LPWSTR* out
  pcKey: Pointer;   // DWORD* out
  ppVal: PPWideChar;   // LPWSTR* out
  pcVal: Pointer   // DWORD* out
): DWORD; stdcall;
  external 'DSPARSE.dll' name 'DsGetRdnW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "DsGetRdnW"
  c_DsGetRdnW :: Ptr CWString -> Ptr Word32 -> Ptr CWString -> Ptr Word32 -> Ptr CWString -> Ptr Word32 -> IO Word32
-- ppDN : LPWSTR* in/out -> Ptr CWString
-- pcDN : DWORD* in/out -> Ptr Word32
-- ppKey : LPWSTR* out -> Ptr CWString
-- pcKey : DWORD* out -> Ptr Word32
-- ppVal : LPWSTR* out -> Ptr CWString
-- pcVal : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let dsgetrdnw =
  foreign "DsGetRdnW"
    ((ptr (ptr uint16_t)) @-> (ptr uint32_t) @-> (ptr (ptr uint16_t)) @-> (ptr uint32_t) @-> (ptr (ptr uint16_t)) @-> (ptr uint32_t) @-> returning uint32_t)
(* ppDN : LPWSTR* in/out -> (ptr (ptr uint16_t)) *)
(* pcDN : DWORD* in/out -> (ptr uint32_t) *)
(* ppKey : LPWSTR* out -> (ptr (ptr uint16_t)) *)
(* pcKey : DWORD* out -> (ptr uint32_t) *)
(* ppVal : LPWSTR* out -> (ptr (ptr uint16_t)) *)
(* pcVal : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library dsparse (t "DSPARSE.dll"))
(cffi:use-foreign-library dsparse)

(cffi:defcfun ("DsGetRdnW" ds-get-rdn-w :convention :stdcall) :uint32
  (pp-dn :pointer)   ; LPWSTR* in/out
  (pc-dn :pointer)   ; DWORD* in/out
  (pp-key :pointer)   ; LPWSTR* out
  (pc-key :pointer)   ; DWORD* out
  (pp-val :pointer)   ; LPWSTR* out
  (pc-val :pointer))   ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $DsGetRdnW = Win32::API::More->new('DSPARSE',
    'DWORD DsGetRdnW(LPVOID ppDN, LPVOID pcDN, LPVOID ppKey, LPVOID pcKey, LPVOID ppVal, LPVOID pcVal)');
# my $ret = $DsGetRdnW->Call($ppDN, $pcDN, $ppKey, $pcKey, $ppVal, $pcVal);
# ppDN : LPWSTR* in/out -> LPVOID
# pcDN : DWORD* in/out -> LPVOID
# ppKey : LPWSTR* out -> LPVOID
# pcKey : DWORD* out -> LPVOID
# ppVal : LPWSTR* out -> LPVOID
# pcVal : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。