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

DsQuoteRdnValueA

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

シグネチャ

// DSPARSE.dll  (ANSI / -A)
#include <windows.h>

DWORD DsQuoteRdnValueA(
    DWORD cUnquotedRdnValueLength,
    LPCSTR psUnquotedRdnValue,
    DWORD* pcQuotedRdnValueLength,
    LPSTR psQuotedRdnValue
);

パラメーター

名前方向
cUnquotedRdnValueLengthDWORDin
psUnquotedRdnValueLPCSTRin
pcQuotedRdnValueLengthDWORD*inout
psQuotedRdnValueLPSTRout

戻り値の型: DWORD

各言語での呼び出し定義

// DSPARSE.dll  (ANSI / -A)
#include <windows.h>

DWORD DsQuoteRdnValueA(
    DWORD cUnquotedRdnValueLength,
    LPCSTR psUnquotedRdnValue,
    DWORD* pcQuotedRdnValueLength,
    LPSTR psQuotedRdnValue
);
[DllImport("DSPARSE.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint DsQuoteRdnValueA(
    uint cUnquotedRdnValueLength,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] string psUnquotedRdnValue,   // LPCSTR
    ref uint pcQuotedRdnValueLength,   // DWORD* in/out
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder psQuotedRdnValue   // LPSTR out
);
<DllImport("DSPARSE.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function DsQuoteRdnValueA(
    cUnquotedRdnValueLength As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPStr)> psUnquotedRdnValue As String,   ' LPCSTR
    ByRef pcQuotedRdnValueLength As UInteger,   ' DWORD* in/out
    <MarshalAs(UnmanagedType.LPStr)> psQuotedRdnValue As System.Text.StringBuilder   ' LPSTR out
) As UInteger
End Function
' cUnquotedRdnValueLength : DWORD
' psUnquotedRdnValue : LPCSTR
' pcQuotedRdnValueLength : DWORD* in/out
' psQuotedRdnValue : LPSTR out
Declare PtrSafe Function DsQuoteRdnValueA Lib "dsparse" ( _
    ByVal cUnquotedRdnValueLength As Long, _
    ByVal psUnquotedRdnValue As String, _
    ByRef pcQuotedRdnValueLength As Long, _
    ByVal psQuotedRdnValue As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

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

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

var (
	dsparse = windows.NewLazySystemDLL("DSPARSE.dll")
	procDsQuoteRdnValueA = dsparse.NewProc("DsQuoteRdnValueA")
)

// cUnquotedRdnValueLength (DWORD), psUnquotedRdnValue (LPCSTR), pcQuotedRdnValueLength (DWORD* in/out), psQuotedRdnValue (LPSTR out)
r1, _, err := procDsQuoteRdnValueA.Call(
	uintptr(cUnquotedRdnValueLength),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(psUnquotedRdnValue))),
	uintptr(pcQuotedRdnValueLength),
	uintptr(psQuotedRdnValue),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function DsQuoteRdnValueA(
  cUnquotedRdnValueLength: DWORD;   // DWORD
  psUnquotedRdnValue: PAnsiChar;   // LPCSTR
  pcQuotedRdnValueLength: Pointer;   // DWORD* in/out
  psQuotedRdnValue: PAnsiChar   // LPSTR out
): DWORD; stdcall;
  external 'DSPARSE.dll' name 'DsQuoteRdnValueA';
result := DllCall("DSPARSE\DsQuoteRdnValueA"
    , "UInt", cUnquotedRdnValueLength   ; DWORD
    , "AStr", psUnquotedRdnValue   ; LPCSTR
    , "Ptr", pcQuotedRdnValueLength   ; DWORD* in/out
    , "Ptr", psQuotedRdnValue   ; LPSTR out
    , "UInt")   ; return: DWORD
●DsQuoteRdnValueA(cUnquotedRdnValueLength, psUnquotedRdnValue, pcQuotedRdnValueLength, psQuotedRdnValue) = DLL("DSPARSE.dll", "dword DsQuoteRdnValueA(dword, char*, void*, char*)")
# 呼び出し: DsQuoteRdnValueA(cUnquotedRdnValueLength, psUnquotedRdnValue, pcQuotedRdnValueLength, psQuotedRdnValue)
# cUnquotedRdnValueLength : DWORD -> "dword"
# psUnquotedRdnValue : LPCSTR -> "char*"
# pcQuotedRdnValueLength : DWORD* in/out -> "void*"
# psQuotedRdnValue : LPSTR out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。