Win32 API 日本語リファレンス
ホームUI.Controls › DPA_SetPtr

DPA_SetPtr

関数
動的ポインタ配列の指定位置にポインタを設定する。
DLLCOMCTL32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

BOOL DPA_SetPtr(
    HDPA hdpa,
    INT i,
    void* p   // optional
);

パラメーター

名前方向
hdpaHDPAin
iINTin
pvoid*inoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL DPA_SetPtr(
    HDPA hdpa,
    INT i,
    void* p   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("COMCTL32.dll", ExactSpelling = true)]
static extern bool DPA_SetPtr(
    IntPtr hdpa,   // HDPA
    int i,   // INT
    IntPtr p   // void* optional
);
<DllImport("COMCTL32.dll", ExactSpelling:=True)>
Public Shared Function DPA_SetPtr(
    hdpa As IntPtr,   ' HDPA
    i As Integer,   ' INT
    p As IntPtr   ' void* optional
) As Boolean
End Function
' hdpa : HDPA
' i : INT
' p : void* optional
Declare PtrSafe Function DPA_SetPtr Lib "comctl32" ( _
    ByVal hdpa As LongPtr, _
    ByVal i As Long, _
    ByVal p As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DPA_SetPtr = ctypes.windll.comctl32.DPA_SetPtr
DPA_SetPtr.restype = wintypes.BOOL
DPA_SetPtr.argtypes = [
    ctypes.c_ssize_t,  # hdpa : HDPA
    ctypes.c_int,  # i : INT
    ctypes.POINTER(None),  # p : void* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('COMCTL32.dll')
DPA_SetPtr = Fiddle::Function.new(
  lib['DPA_SetPtr'],
  [
    Fiddle::TYPE_INTPTR_T,  # hdpa : HDPA
    Fiddle::TYPE_INT,  # i : INT
    Fiddle::TYPE_VOIDP,  # p : void* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "comctl32")]
extern "system" {
    fn DPA_SetPtr(
        hdpa: isize,  // HDPA
        i: i32,  // INT
        p: *mut ()  // void* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("COMCTL32.dll")]
public static extern bool DPA_SetPtr(IntPtr hdpa, int i, IntPtr p);
"@
$api = Add-Type -MemberDefinition $sig -Name 'COMCTL32_DPA_SetPtr' -Namespace Win32 -PassThru
# $api::DPA_SetPtr(hdpa, i, p)
#uselib "COMCTL32.dll"
#func global DPA_SetPtr "DPA_SetPtr" sptr, sptr, sptr
; DPA_SetPtr hdpa, i, p   ; 戻り値は stat
; hdpa : HDPA -> "sptr"
; i : INT -> "sptr"
; p : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "COMCTL32.dll"
#cfunc global DPA_SetPtr "DPA_SetPtr" sptr, int, sptr
; res = DPA_SetPtr(hdpa, i, p)
; hdpa : HDPA -> "sptr"
; i : INT -> "int"
; p : void* optional -> "sptr"
; BOOL DPA_SetPtr(HDPA hdpa, INT i, void* p)
#uselib "COMCTL32.dll"
#cfunc global DPA_SetPtr "DPA_SetPtr" intptr, int, intptr
; res = DPA_SetPtr(hdpa, i, p)
; hdpa : HDPA -> "intptr"
; i : INT -> "int"
; p : void* optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
	procDPA_SetPtr = comctl32.NewProc("DPA_SetPtr")
)

// hdpa (HDPA), i (INT), p (void* optional)
r1, _, err := procDPA_SetPtr.Call(
	uintptr(hdpa),
	uintptr(i),
	uintptr(p),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function DPA_SetPtr(
  hdpa: NativeInt;   // HDPA
  i: Integer;   // INT
  p: Pointer   // void* optional
): BOOL; stdcall;
  external 'COMCTL32.dll' name 'DPA_SetPtr';
result := DllCall("COMCTL32\DPA_SetPtr"
    , "Ptr", hdpa   ; HDPA
    , "Int", i   ; INT
    , "Ptr", p   ; void* optional
    , "Int")   ; return: BOOL
●DPA_SetPtr(hdpa, i, p) = DLL("COMCTL32.dll", "bool DPA_SetPtr(int, int, void*)")
# 呼び出し: DPA_SetPtr(hdpa, i, p)
# hdpa : HDPA -> "int"
# i : INT -> "int"
# p : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。