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

DsUnquoteRdnValueW

関数
引用されたRDN値のエスケープを解除する(Unicode版)。
DLLDSPARSE.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD DsUnquoteRdnValueW(
    DWORD cQuotedRdnValueLength,
    LPCWSTR psQuotedRdnValue,
    DWORD* pcUnquotedRdnValueLength,
    LPWSTR psUnquotedRdnValue
);

パラメーター

名前方向
cQuotedRdnValueLengthDWORDin
psQuotedRdnValueLPCWSTRin
pcUnquotedRdnValueLengthDWORD*inout
psUnquotedRdnValueLPWSTRout

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD DsUnquoteRdnValueW(
    DWORD cQuotedRdnValueLength,
    LPCWSTR psQuotedRdnValue,
    DWORD* pcUnquotedRdnValueLength,
    LPWSTR psUnquotedRdnValue
);
[DllImport("DSPARSE.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint DsUnquoteRdnValueW(
    uint cQuotedRdnValueLength,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string psQuotedRdnValue,   // LPCWSTR
    ref uint pcUnquotedRdnValueLength,   // DWORD* in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder psUnquotedRdnValue   // LPWSTR out
);
<DllImport("DSPARSE.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function DsUnquoteRdnValueW(
    cQuotedRdnValueLength As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> psQuotedRdnValue As String,   ' LPCWSTR
    ByRef pcUnquotedRdnValueLength As UInteger,   ' DWORD* in/out
    <MarshalAs(UnmanagedType.LPWStr)> psUnquotedRdnValue As System.Text.StringBuilder   ' LPWSTR out
) As UInteger
End Function
' cQuotedRdnValueLength : DWORD
' psQuotedRdnValue : LPCWSTR
' pcUnquotedRdnValueLength : DWORD* in/out
' psUnquotedRdnValue : LPWSTR out
Declare PtrSafe Function DsUnquoteRdnValueW Lib "dsparse" ( _
    ByVal cQuotedRdnValueLength As Long, _
    ByVal psQuotedRdnValue As LongPtr, _
    ByRef pcUnquotedRdnValueLength As Long, _
    ByVal psUnquotedRdnValue 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

DsUnquoteRdnValueW = ctypes.windll.dsparse.DsUnquoteRdnValueW
DsUnquoteRdnValueW.restype = wintypes.DWORD
DsUnquoteRdnValueW.argtypes = [
    wintypes.DWORD,  # cQuotedRdnValueLength : DWORD
    wintypes.LPCWSTR,  # psQuotedRdnValue : LPCWSTR
    ctypes.POINTER(wintypes.DWORD),  # pcUnquotedRdnValueLength : DWORD* in/out
    wintypes.LPWSTR,  # psUnquotedRdnValue : LPWSTR out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	dsparse = windows.NewLazySystemDLL("DSPARSE.dll")
	procDsUnquoteRdnValueW = dsparse.NewProc("DsUnquoteRdnValueW")
)

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