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

ReallocADsStr

関数
ADSI用文字列を新しい値で再確保する。
DLLACTIVEDS.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

BOOL ReallocADsStr(
    LPWSTR* ppStr,
    LPWSTR pStr
);

パラメーター

名前方向
ppStrLPWSTR*inout
pStrLPWSTRin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL ReallocADsStr(
    LPWSTR* ppStr,
    LPWSTR pStr
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ACTIVEDS.dll", ExactSpelling = true)]
static extern bool ReallocADsStr(
    IntPtr ppStr,   // LPWSTR* in/out
    [MarshalAs(UnmanagedType.LPWStr)] string pStr   // LPWSTR
);
<DllImport("ACTIVEDS.dll", ExactSpelling:=True)>
Public Shared Function ReallocADsStr(
    ppStr As IntPtr,   ' LPWSTR* in/out
    <MarshalAs(UnmanagedType.LPWStr)> pStr As String   ' LPWSTR
) As Boolean
End Function
' ppStr : LPWSTR* in/out
' pStr : LPWSTR
Declare PtrSafe Function ReallocADsStr Lib "activeds" ( _
    ByVal ppStr As LongPtr, _
    ByVal pStr As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ReallocADsStr = ctypes.windll.activeds.ReallocADsStr
ReallocADsStr.restype = wintypes.BOOL
ReallocADsStr.argtypes = [
    ctypes.c_void_p,  # ppStr : LPWSTR* in/out
    wintypes.LPCWSTR,  # pStr : LPWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ACTIVEDS.dll')
ReallocADsStr = Fiddle::Function.new(
  lib['ReallocADsStr'],
  [
    Fiddle::TYPE_VOIDP,  # ppStr : LPWSTR* in/out
    Fiddle::TYPE_VOIDP,  # pStr : LPWSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "activeds")]
extern "system" {
    fn ReallocADsStr(
        ppStr: *mut *mut u16,  // LPWSTR* in/out
        pStr: *mut u16  // LPWSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ACTIVEDS.dll")]
public static extern bool ReallocADsStr(IntPtr ppStr, [MarshalAs(UnmanagedType.LPWStr)] string pStr);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ACTIVEDS_ReallocADsStr' -Namespace Win32 -PassThru
# $api::ReallocADsStr(ppStr, pStr)
#uselib "ACTIVEDS.dll"
#func global ReallocADsStr "ReallocADsStr" sptr, sptr
; ReallocADsStr varptr(ppStr), pStr   ; 戻り値は stat
; ppStr : LPWSTR* in/out -> "sptr"
; pStr : LPWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ACTIVEDS.dll"
#cfunc global ReallocADsStr "ReallocADsStr" var, wstr
; res = ReallocADsStr(ppStr, pStr)
; ppStr : LPWSTR* in/out -> "var"
; pStr : LPWSTR -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL ReallocADsStr(LPWSTR* ppStr, LPWSTR pStr)
#uselib "ACTIVEDS.dll"
#cfunc global ReallocADsStr "ReallocADsStr" var, wstr
; res = ReallocADsStr(ppStr, pStr)
; ppStr : LPWSTR* in/out -> "var"
; pStr : LPWSTR -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	activeds = windows.NewLazySystemDLL("ACTIVEDS.dll")
	procReallocADsStr = activeds.NewProc("ReallocADsStr")
)

// ppStr (LPWSTR* in/out), pStr (LPWSTR)
r1, _, err := procReallocADsStr.Call(
	uintptr(ppStr),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pStr))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function ReallocADsStr(
  ppStr: PPWideChar;   // LPWSTR* in/out
  pStr: PWideChar   // LPWSTR
): BOOL; stdcall;
  external 'ACTIVEDS.dll' name 'ReallocADsStr';
result := DllCall("ACTIVEDS\ReallocADsStr"
    , "Ptr", ppStr   ; LPWSTR* in/out
    , "WStr", pStr   ; LPWSTR
    , "Int")   ; return: BOOL
●ReallocADsStr(ppStr, pStr) = DLL("ACTIVEDS.dll", "bool ReallocADsStr(void*, char*)")
# 呼び出し: ReallocADsStr(ppStr, pStr)
# ppStr : LPWSTR* in/out -> "void*"
# pStr : LPWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。