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

DPA_GetPtr

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

シグネチャ

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

void* DPA_GetPtr(
    HDPA hdpa,
    INT_PTR i
);

パラメーター

名前方向説明
hdpaHDPAinDPA へのハンドル。
iINT_PTRin取得する項目のインデックス。

戻り値の型: void*

公式ドキュメント

動的ポインター配列 (DPA) から項目を取得します。

戻り値

指定した項目を返します。呼び出しが失敗した場合は NULL を返します。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

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

DPA_GetPtr = ctypes.windll.comctl32.DPA_GetPtr
DPA_GetPtr.restype = ctypes.c_void_p
DPA_GetPtr.argtypes = [
    ctypes.c_ssize_t,  # hdpa : HDPA
    ctypes.c_ssize_t,  # i : INT_PTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
	procDPA_GetPtr = comctl32.NewProc("DPA_GetPtr")
)

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

extern "comctl32" fn DPA_GetPtr(
    hdpa: isize, // HDPA
    i: isize // INT_PTR
) callconv(std.os.windows.WINAPI) ?*anyopaque;
proc DPA_GetPtr(
    hdpa: int,  # HDPA
    i: int  # INT_PTR
): pointer {.importc: "DPA_GetPtr", stdcall, dynlib: "COMCTL32.dll".}
pragma(lib, "comctl32");
extern(Windows)
void* DPA_GetPtr(
    ptrdiff_t hdpa,   // HDPA
    ptrdiff_t i   // INT_PTR
);
ccall((:DPA_GetPtr, "COMCTL32.dll"), stdcall, Ptr{Cvoid},
      (Int, Int),
      hdpa, i)
# hdpa : HDPA -> Int
# i : INT_PTR -> Int
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
void* DPA_GetPtr(
    intptr_t hdpa,
    intptr_t i);
]]
local comctl32 = ffi.load("comctl32")
-- comctl32.DPA_GetPtr(hdpa, i)
-- hdpa : HDPA
-- i : INT_PTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('COMCTL32.dll');
const DPA_GetPtr = lib.func('__stdcall', 'DPA_GetPtr', 'void *', ['intptr_t', 'intptr_t']);
// DPA_GetPtr(hdpa, i)
// hdpa : HDPA -> 'intptr_t'
// i : INT_PTR -> 'intptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("COMCTL32.dll", {
  DPA_GetPtr: { parameters: ["isize", "isize"], result: "pointer" },
});
// lib.symbols.DPA_GetPtr(hdpa, i)
// hdpa : HDPA -> "isize"
// i : INT_PTR -> "isize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void* DPA_GetPtr(
    intptr_t hdpa,
    intptr_t i);
C, "COMCTL32.dll");
// $ffi->DPA_GetPtr(hdpa, i);
// hdpa : HDPA
// i : INT_PTR
// 構造体/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);
    Pointer DPA_GetPtr(
        long hdpa,   // HDPA
        long i   // INT_PTR
    );
}
@[Link("comctl32")]
lib LibCOMCTL32
  fun DPA_GetPtr = DPA_GetPtr(
    hdpa : LibC::SSizeT,   # HDPA
    i : LibC::SSizeT   # INT_PTR
  ) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef DPA_GetPtrNative = Pointer<Void> Function(IntPtr, IntPtr);
typedef DPA_GetPtrDart = Pointer<Void> Function(int, int);
final DPA_GetPtr = DynamicLibrary.open('COMCTL32.dll')
    .lookupFunction<DPA_GetPtrNative, DPA_GetPtrDart>('DPA_GetPtr');
// hdpa : HDPA -> IntPtr
// i : INT_PTR -> IntPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function DPA_GetPtr(
  hdpa: NativeInt;   // HDPA
  i: NativeInt   // INT_PTR
): Pointer; stdcall;
  external 'COMCTL32.dll' name 'DPA_GetPtr';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "DPA_GetPtr"
  c_DPA_GetPtr :: CIntPtr -> CIntPtr -> IO (Ptr ())
-- hdpa : HDPA -> CIntPtr
-- i : INT_PTR -> CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let dpa_getptr =
  foreign "DPA_GetPtr"
    (intptr_t @-> intptr_t @-> returning (ptr void))
(* hdpa : HDPA -> intptr_t *)
(* i : INT_PTR -> intptr_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library comctl32 (t "COMCTL32.dll"))
(cffi:use-foreign-library comctl32)

(cffi:defcfun ("DPA_GetPtr" dpa-get-ptr :convention :stdcall) :pointer
  (hdpa :int64)   ; HDPA
  (i :int64))   ; INT_PTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $DPA_GetPtr = Win32::API::More->new('COMCTL32',
    'LPVOID DPA_GetPtr(LPARAM hdpa, LPARAM i)');
# my $ret = $DPA_GetPtr->Call($hdpa, $i);
# hdpa : HDPA -> LPARAM
# i : INT_PTR -> LPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。