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

DPA_GetPtrIndex

関数
動的ポインタ配列内のポインタのインデックスを取得する。
DLLCOMCTL32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

INT DPA_GetPtrIndex(
    HDPA hdpa,
    const void* p   // optional
);

パラメーター

名前方向
hdpaHDPAin
pvoid*inoptional

戻り値の型: INT

各言語での呼び出し定義

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

INT DPA_GetPtrIndex(
    HDPA hdpa,
    const void* p   // optional
);
[DllImport("COMCTL32.dll", ExactSpelling = true)]
static extern int DPA_GetPtrIndex(
    IntPtr hdpa,   // HDPA
    IntPtr p   // void* optional
);
<DllImport("COMCTL32.dll", ExactSpelling:=True)>
Public Shared Function DPA_GetPtrIndex(
    hdpa As IntPtr,   ' HDPA
    p As IntPtr   ' void* optional
) As Integer
End Function
' hdpa : HDPA
' p : void* optional
Declare PtrSafe Function DPA_GetPtrIndex Lib "comctl32" ( _
    ByVal hdpa As LongPtr, _
    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_GetPtrIndex = ctypes.windll.comctl32.DPA_GetPtrIndex
DPA_GetPtrIndex.restype = ctypes.c_int
DPA_GetPtrIndex.argtypes = [
    ctypes.c_ssize_t,  # hdpa : HDPA
    ctypes.POINTER(None),  # p : void* optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
	procDPA_GetPtrIndex = comctl32.NewProc("DPA_GetPtrIndex")
)

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