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

DsQuoteRdnValueW

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

シグネチャ

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

DWORD DsQuoteRdnValueW(
    DWORD cUnquotedRdnValueLength,
    LPCWSTR psUnquotedRdnValue,
    DWORD* pcQuotedRdnValueLength,
    LPWSTR psQuotedRdnValue
);

パラメーター

名前方向
cUnquotedRdnValueLengthDWORDin
psUnquotedRdnValueLPCWSTRin
pcQuotedRdnValueLengthDWORD*inout
psQuotedRdnValueLPWSTRout

戻り値の型: DWORD

各言語での呼び出し定義

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

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

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

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

var (
	dsparse = windows.NewLazySystemDLL("DSPARSE.dll")
	procDsQuoteRdnValueW = dsparse.NewProc("DsQuoteRdnValueW")
)

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