ホーム › UI.Controls › DPA_Search
DPA_Search
関数動的ポインタ配列から要素を検索する。
シグネチャ
// COMCTL32.dll
#include <windows.h>
INT DPA_Search(
HDPA hdpa,
void* pFind, // optional
INT iStart,
PFNDACOMPARE pfnCompare,
LPARAM lParam,
DWORD options
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| hdpa | HDPA | in | DPA へのハンドル。 | ||||||||
| pFind | void* | inoptional | 検索対象へのポインター。 | ||||||||
| iStart | INT | in | 検索を開始するインデックス。 | ||||||||
| pfnCompare | PFNDACOMPARE | in | 比較関数へのポインター。比較関数のプロトタイプについては PFNDPACOMPARE を参照してください。 | ||||||||
| lParam | LPARAM | in | pfnCmp に渡される追加のパラメーター。 | ||||||||
| options | DWORD | in | このパラメーターには、以下の 1 つ以上を指定できます。
|
戻り値の型: INT
公式ドキュメント
動的ポインター配列 (DPA) 内の項目を検索します。
戻り値
Type: int
DPA 内で項目が見つかった場合はそのインデックスを返し、項目が見つからなかった場合は -1 を返します。
出典・ライセンス: 上記「公式ドキュメント」の内容は 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>
INT DPA_Search(
HDPA hdpa,
void* pFind, // optional
INT iStart,
PFNDACOMPARE pfnCompare,
LPARAM lParam,
DWORD options
);[DllImport("COMCTL32.dll", ExactSpelling = true)]
static extern int DPA_Search(
IntPtr hdpa, // HDPA
IntPtr pFind, // void* optional
int iStart, // INT
IntPtr pfnCompare, // PFNDACOMPARE
IntPtr lParam, // LPARAM
uint options // DWORD
);<DllImport("COMCTL32.dll", ExactSpelling:=True)>
Public Shared Function DPA_Search(
hdpa As IntPtr, ' HDPA
pFind As IntPtr, ' void* optional
iStart As Integer, ' INT
pfnCompare As IntPtr, ' PFNDACOMPARE
lParam As IntPtr, ' LPARAM
options As UInteger ' DWORD
) As Integer
End Function' hdpa : HDPA
' pFind : void* optional
' iStart : INT
' pfnCompare : PFNDACOMPARE
' lParam : LPARAM
' options : DWORD
Declare PtrSafe Function DPA_Search Lib "comctl32" ( _
ByVal hdpa As LongPtr, _
ByVal pFind As LongPtr, _
ByVal iStart As Long, _
ByVal pfnCompare As LongPtr, _
ByVal lParam As LongPtr, _
ByVal options As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DPA_Search = ctypes.windll.comctl32.DPA_Search
DPA_Search.restype = ctypes.c_int
DPA_Search.argtypes = [
ctypes.c_ssize_t, # hdpa : HDPA
ctypes.POINTER(None), # pFind : void* optional
ctypes.c_int, # iStart : INT
ctypes.c_void_p, # pfnCompare : PFNDACOMPARE
ctypes.c_ssize_t, # lParam : LPARAM
wintypes.DWORD, # options : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('COMCTL32.dll')
DPA_Search = Fiddle::Function.new(
lib['DPA_Search'],
[
Fiddle::TYPE_INTPTR_T, # hdpa : HDPA
Fiddle::TYPE_VOIDP, # pFind : void* optional
Fiddle::TYPE_INT, # iStart : INT
Fiddle::TYPE_VOIDP, # pfnCompare : PFNDACOMPARE
Fiddle::TYPE_INTPTR_T, # lParam : LPARAM
-Fiddle::TYPE_INT, # options : DWORD
],
Fiddle::TYPE_INT)#[link(name = "comctl32")]
extern "system" {
fn DPA_Search(
hdpa: isize, // HDPA
pFind: *mut (), // void* optional
iStart: i32, // INT
pfnCompare: *const core::ffi::c_void, // PFNDACOMPARE
lParam: isize, // LPARAM
options: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("COMCTL32.dll")]
public static extern int DPA_Search(IntPtr hdpa, IntPtr pFind, int iStart, IntPtr pfnCompare, IntPtr lParam, uint options);
"@
$api = Add-Type -MemberDefinition $sig -Name 'COMCTL32_DPA_Search' -Namespace Win32 -PassThru
# $api::DPA_Search(hdpa, pFind, iStart, pfnCompare, lParam, options)#uselib "COMCTL32.dll"
#func global DPA_Search "DPA_Search" sptr, sptr, sptr, sptr, sptr, sptr
; DPA_Search hdpa, pFind, iStart, pfnCompare, lParam, options ; 戻り値は stat
; hdpa : HDPA -> "sptr"
; pFind : void* optional -> "sptr"
; iStart : INT -> "sptr"
; pfnCompare : PFNDACOMPARE -> "sptr"
; lParam : LPARAM -> "sptr"
; options : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "COMCTL32.dll"
#cfunc global DPA_Search "DPA_Search" sptr, sptr, int, sptr, sptr, int
; res = DPA_Search(hdpa, pFind, iStart, pfnCompare, lParam, options)
; hdpa : HDPA -> "sptr"
; pFind : void* optional -> "sptr"
; iStart : INT -> "int"
; pfnCompare : PFNDACOMPARE -> "sptr"
; lParam : LPARAM -> "sptr"
; options : DWORD -> "int"; INT DPA_Search(HDPA hdpa, void* pFind, INT iStart, PFNDACOMPARE pfnCompare, LPARAM lParam, DWORD options)
#uselib "COMCTL32.dll"
#cfunc global DPA_Search "DPA_Search" intptr, intptr, int, intptr, intptr, int
; res = DPA_Search(hdpa, pFind, iStart, pfnCompare, lParam, options)
; hdpa : HDPA -> "intptr"
; pFind : void* optional -> "intptr"
; iStart : INT -> "int"
; pfnCompare : PFNDACOMPARE -> "intptr"
; lParam : LPARAM -> "intptr"
; options : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
procDPA_Search = comctl32.NewProc("DPA_Search")
)
// hdpa (HDPA), pFind (void* optional), iStart (INT), pfnCompare (PFNDACOMPARE), lParam (LPARAM), options (DWORD)
r1, _, err := procDPA_Search.Call(
uintptr(hdpa),
uintptr(pFind),
uintptr(iStart),
uintptr(pfnCompare),
uintptr(lParam),
uintptr(options),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction DPA_Search(
hdpa: NativeInt; // HDPA
pFind: Pointer; // void* optional
iStart: Integer; // INT
pfnCompare: Pointer; // PFNDACOMPARE
lParam: NativeInt; // LPARAM
options: DWORD // DWORD
): Integer; stdcall;
external 'COMCTL32.dll' name 'DPA_Search';result := DllCall("COMCTL32\DPA_Search"
, "Ptr", hdpa ; HDPA
, "Ptr", pFind ; void* optional
, "Int", iStart ; INT
, "Ptr", pfnCompare ; PFNDACOMPARE
, "Ptr", lParam ; LPARAM
, "UInt", options ; DWORD
, "Int") ; return: INT●DPA_Search(hdpa, pFind, iStart, pfnCompare, lParam, options) = DLL("COMCTL32.dll", "int DPA_Search(int, void*, int, void*, int, dword)")
# 呼び出し: DPA_Search(hdpa, pFind, iStart, pfnCompare, lParam, options)
# hdpa : HDPA -> "int"
# pFind : void* optional -> "void*"
# iStart : INT -> "int"
# pfnCompare : PFNDACOMPARE -> "void*"
# lParam : LPARAM -> "int"
# options : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "comctl32" fn DPA_Search(
hdpa: isize, // HDPA
pFind: ?*anyopaque, // void* optional
iStart: i32, // INT
pfnCompare: ?*anyopaque, // PFNDACOMPARE
lParam: isize, // LPARAM
options: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc DPA_Search(
hdpa: int, # HDPA
pFind: pointer, # void* optional
iStart: int32, # INT
pfnCompare: pointer, # PFNDACOMPARE
lParam: int, # LPARAM
options: uint32 # DWORD
): int32 {.importc: "DPA_Search", stdcall, dynlib: "COMCTL32.dll".}pragma(lib, "comctl32");
extern(Windows)
int DPA_Search(
ptrdiff_t hdpa, // HDPA
void* pFind, // void* optional
int iStart, // INT
void* pfnCompare, // PFNDACOMPARE
ptrdiff_t lParam, // LPARAM
uint options // DWORD
);ccall((:DPA_Search, "COMCTL32.dll"), stdcall, Int32,
(Int, Ptr{Cvoid}, Int32, Ptr{Cvoid}, Int, UInt32),
hdpa, pFind, iStart, pfnCompare, lParam, options)
# hdpa : HDPA -> Int
# pFind : void* optional -> Ptr{Cvoid}
# iStart : INT -> Int32
# pfnCompare : PFNDACOMPARE -> Ptr{Cvoid}
# lParam : LPARAM -> Int
# options : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DPA_Search(
intptr_t hdpa,
void* pFind,
int32_t iStart,
void* pfnCompare,
intptr_t lParam,
uint32_t options);
]]
local comctl32 = ffi.load("comctl32")
-- comctl32.DPA_Search(hdpa, pFind, iStart, pfnCompare, lParam, options)
-- hdpa : HDPA
-- pFind : void* optional
-- iStart : INT
-- pfnCompare : PFNDACOMPARE
-- lParam : LPARAM
-- options : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('COMCTL32.dll');
const DPA_Search = lib.func('__stdcall', 'DPA_Search', 'int32_t', ['intptr_t', 'void *', 'int32_t', 'void *', 'intptr_t', 'uint32_t']);
// DPA_Search(hdpa, pFind, iStart, pfnCompare, lParam, options)
// hdpa : HDPA -> 'intptr_t'
// pFind : void* optional -> 'void *'
// iStart : INT -> 'int32_t'
// pfnCompare : PFNDACOMPARE -> 'void *'
// lParam : LPARAM -> 'intptr_t'
// options : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。const lib = Deno.dlopen("COMCTL32.dll", {
DPA_Search: { parameters: ["isize", "pointer", "i32", "pointer", "isize", "u32"], result: "i32" },
});
// lib.symbols.DPA_Search(hdpa, pFind, iStart, pfnCompare, lParam, options)
// hdpa : HDPA -> "isize"
// pFind : void* optional -> "pointer"
// iStart : INT -> "i32"
// pfnCompare : PFNDACOMPARE -> "pointer"
// lParam : LPARAM -> "isize"
// options : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DPA_Search(
intptr_t hdpa,
void* pFind,
int32_t iStart,
void* pfnCompare,
intptr_t lParam,
uint32_t options);
C, "COMCTL32.dll");
// $ffi->DPA_Search(hdpa, pFind, iStart, pfnCompare, lParam, options);
// hdpa : HDPA
// pFind : void* optional
// iStart : INT
// pfnCompare : PFNDACOMPARE
// lParam : LPARAM
// options : DWORD
// 構造体/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);
int DPA_Search(
long hdpa, // HDPA
Pointer pFind, // void* optional
int iStart, // INT
Callback pfnCompare, // PFNDACOMPARE
long lParam, // LPARAM
int options // DWORD
);
}@[Link("comctl32")]
lib LibCOMCTL32
fun DPA_Search = DPA_Search(
hdpa : LibC::SSizeT, # HDPA
pFind : Void*, # void* optional
iStart : Int32, # INT
pfnCompare : Void*, # PFNDACOMPARE
lParam : LibC::SSizeT, # LPARAM
options : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DPA_SearchNative = Int32 Function(IntPtr, Pointer<Void>, Int32, Pointer<Void>, IntPtr, Uint32);
typedef DPA_SearchDart = int Function(int, Pointer<Void>, int, Pointer<Void>, int, int);
final DPA_Search = DynamicLibrary.open('COMCTL32.dll')
.lookupFunction<DPA_SearchNative, DPA_SearchDart>('DPA_Search');
// hdpa : HDPA -> IntPtr
// pFind : void* optional -> Pointer<Void>
// iStart : INT -> Int32
// pfnCompare : PFNDACOMPARE -> Pointer<Void>
// lParam : LPARAM -> IntPtr
// options : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DPA_Search(
hdpa: NativeInt; // HDPA
pFind: Pointer; // void* optional
iStart: Integer; // INT
pfnCompare: Pointer; // PFNDACOMPARE
lParam: NativeInt; // LPARAM
options: DWORD // DWORD
): Integer; stdcall;
external 'COMCTL32.dll' name 'DPA_Search';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DPA_Search"
c_DPA_Search :: CIntPtr -> Ptr () -> Int32 -> Ptr () -> CIntPtr -> Word32 -> IO Int32
-- hdpa : HDPA -> CIntPtr
-- pFind : void* optional -> Ptr ()
-- iStart : INT -> Int32
-- pfnCompare : PFNDACOMPARE -> Ptr ()
-- lParam : LPARAM -> CIntPtr
-- options : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dpa_search =
foreign "DPA_Search"
(intptr_t @-> (ptr void) @-> int32_t @-> (ptr void) @-> intptr_t @-> uint32_t @-> returning int32_t)
(* hdpa : HDPA -> intptr_t *)
(* pFind : void* optional -> (ptr void) *)
(* iStart : INT -> int32_t *)
(* pfnCompare : PFNDACOMPARE -> (ptr void) *)
(* lParam : LPARAM -> intptr_t *)
(* options : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library comctl32 (t "COMCTL32.dll"))
(cffi:use-foreign-library comctl32)
(cffi:defcfun ("DPA_Search" dpa-search :convention :stdcall) :int32
(hdpa :int64) ; HDPA
(p-find :pointer) ; void* optional
(i-start :int32) ; INT
(pfn-compare :pointer) ; PFNDACOMPARE
(l-param :int64) ; LPARAM
(options :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DPA_Search = Win32::API::More->new('COMCTL32',
'int DPA_Search(LPARAM hdpa, LPVOID pFind, int iStart, LPVOID pfnCompare, LPARAM lParam, DWORD options)');
# my $ret = $DPA_Search->Call($hdpa, $pFind, $iStart, $pfnCompare, $lParam, $options);
# hdpa : HDPA -> LPARAM
# pFind : void* optional -> LPVOID
# iStart : INT -> int
# pfnCompare : PFNDACOMPARE -> LPVOID
# lParam : LPARAM -> LPARAM
# options : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。関連項目
使用する型