ホーム › UI.Controls › DPA_SetPtr
DPA_SetPtr
関数動的ポインタ配列の指定位置にポインタを設定する。
シグネチャ
// COMCTL32.dll
#include <windows.h>
BOOL DPA_SetPtr(
HDPA hdpa,
INT i,
void* p // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdpa | HDPA | in | DPA へのハンドルです。 |
| i | INT | in | DPA 内の項目のインデックスです。 注意 インデックスが現在の DPA のサイズを超えている場合、DPA はそれに対応できるように拡張されます。項目を連続して割り当てる必要はありません。
|
| p | void* | inoptional | 指定した DPA 項目に割り当てる値へのポインターです。 |
戻り値の型: BOOL
公式ドキュメント
動的ポインター配列 (DPA) 内の項目に値を割り当てます。
戻り値
型: BOOL
成功した場合は TRUE を、それ以外の場合は FALSE を返します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 <MarshalAs(UnmanagedType.Bool)> 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 // BOOLfunction 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)。const std = @import("std");
extern "comctl32" fn DPA_SetPtr(
hdpa: isize, // HDPA
i: i32, // INT
p: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) i32;proc DPA_SetPtr(
hdpa: int, # HDPA
i: int32, # INT
p: pointer # void* optional
): int32 {.importc: "DPA_SetPtr", stdcall, dynlib: "COMCTL32.dll".}pragma(lib, "comctl32");
extern(Windows)
int DPA_SetPtr(
ptrdiff_t hdpa, // HDPA
int i, // INT
void* p // void* optional
);ccall((:DPA_SetPtr, "COMCTL32.dll"), stdcall, Int32,
(Int, Int32, Ptr{Cvoid}),
hdpa, i, p)
# hdpa : HDPA -> Int
# i : INT -> Int32
# p : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DPA_SetPtr(
intptr_t hdpa,
int32_t i,
void* p);
]]
local comctl32 = ffi.load("comctl32")
-- comctl32.DPA_SetPtr(hdpa, i, p)
-- hdpa : HDPA
-- i : INT
-- p : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('COMCTL32.dll');
const DPA_SetPtr = lib.func('__stdcall', 'DPA_SetPtr', 'int32_t', ['intptr_t', 'int32_t', 'void *']);
// DPA_SetPtr(hdpa, i, p)
// hdpa : HDPA -> 'intptr_t'
// i : INT -> 'int32_t'
// p : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("COMCTL32.dll", {
DPA_SetPtr: { parameters: ["isize", "i32", "pointer"], result: "i32" },
});
// lib.symbols.DPA_SetPtr(hdpa, i, p)
// hdpa : HDPA -> "isize"
// i : INT -> "i32"
// p : void* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DPA_SetPtr(
intptr_t hdpa,
int32_t i,
void* p);
C, "COMCTL32.dll");
// $ffi->DPA_SetPtr(hdpa, i, p);
// hdpa : HDPA
// i : INT
// p : void* optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Comctl32 extends StdCallLibrary {
Comctl32 INSTANCE = Native.load("comctl32", Comctl32.class);
boolean DPA_SetPtr(
long hdpa, // HDPA
int i, // INT
Pointer p // void* optional
);
}@[Link("comctl32")]
lib LibCOMCTL32
fun DPA_SetPtr = DPA_SetPtr(
hdpa : LibC::SSizeT, # HDPA
i : Int32, # INT
p : Void* # void* optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DPA_SetPtrNative = Int32 Function(IntPtr, Int32, Pointer<Void>);
typedef DPA_SetPtrDart = int Function(int, int, Pointer<Void>);
final DPA_SetPtr = DynamicLibrary.open('COMCTL32.dll')
.lookupFunction<DPA_SetPtrNative, DPA_SetPtrDart>('DPA_SetPtr');
// hdpa : HDPA -> IntPtr
// i : INT -> Int32
// p : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DPA_SetPtr(
hdpa: NativeInt; // HDPA
i: Integer; // INT
p: Pointer // void* optional
): BOOL; stdcall;
external 'COMCTL32.dll' name 'DPA_SetPtr';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DPA_SetPtr"
c_DPA_SetPtr :: CIntPtr -> Int32 -> Ptr () -> IO CInt
-- hdpa : HDPA -> CIntPtr
-- i : INT -> Int32
-- p : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dpa_setptr =
foreign "DPA_SetPtr"
(intptr_t @-> int32_t @-> (ptr void) @-> returning int32_t)
(* hdpa : HDPA -> intptr_t *)
(* i : INT -> int32_t *)
(* p : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library comctl32 (t "COMCTL32.dll"))
(cffi:use-foreign-library comctl32)
(cffi:defcfun ("DPA_SetPtr" dpa-set-ptr :convention :stdcall) :int32
(hdpa :int64) ; HDPA
(i :int32) ; INT
(p :pointer)) ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DPA_SetPtr = Win32::API::More->new('COMCTL32',
'BOOL DPA_SetPtr(LPARAM hdpa, int i, LPVOID p)');
# my $ret = $DPA_SetPtr->Call($hdpa, $i, $p);
# hdpa : HDPA -> LPARAM
# i : INT -> int
# p : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。