ホーム › System.EventCollector › EcInsertObjectArrayElement
EcInsertObjectArrayElement
関数オブジェクト配列に新しい要素を挿入する。
シグネチャ
// WecApi.dll
#include <windows.h>
BOOL EcInsertObjectArrayElement(
INT_PTR ObjectArray,
DWORD ArrayIndex
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ObjectArray | INT_PTR | in | 要素を挿入する対象のオブジェクト配列ハンドル。 |
| ArrayIndex | DWORD | in | 新しい空要素を挿入する0基点の位置を指定する。 |
戻り値の型: BOOL
各言語での呼び出し定義
// WecApi.dll
#include <windows.h>
BOOL EcInsertObjectArrayElement(
INT_PTR ObjectArray,
DWORD ArrayIndex
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WecApi.dll", ExactSpelling = true)]
static extern bool EcInsertObjectArrayElement(
IntPtr ObjectArray, // INT_PTR
uint ArrayIndex // DWORD
);<DllImport("WecApi.dll", ExactSpelling:=True)>
Public Shared Function EcInsertObjectArrayElement(
ObjectArray As IntPtr, ' INT_PTR
ArrayIndex As UInteger ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' ObjectArray : INT_PTR
' ArrayIndex : DWORD
Declare PtrSafe Function EcInsertObjectArrayElement Lib "wecapi" ( _
ByVal ObjectArray As LongPtr, _
ByVal ArrayIndex As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
EcInsertObjectArrayElement = ctypes.windll.wecapi.EcInsertObjectArrayElement
EcInsertObjectArrayElement.restype = wintypes.BOOL
EcInsertObjectArrayElement.argtypes = [
ctypes.c_ssize_t, # ObjectArray : INT_PTR
wintypes.DWORD, # ArrayIndex : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WecApi.dll')
EcInsertObjectArrayElement = Fiddle::Function.new(
lib['EcInsertObjectArrayElement'],
[
Fiddle::TYPE_INTPTR_T, # ObjectArray : INT_PTR
-Fiddle::TYPE_INT, # ArrayIndex : DWORD
],
Fiddle::TYPE_INT)#[link(name = "wecapi")]
extern "system" {
fn EcInsertObjectArrayElement(
ObjectArray: isize, // INT_PTR
ArrayIndex: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WecApi.dll")]
public static extern bool EcInsertObjectArrayElement(IntPtr ObjectArray, uint ArrayIndex);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WecApi_EcInsertObjectArrayElement' -Namespace Win32 -PassThru
# $api::EcInsertObjectArrayElement(ObjectArray, ArrayIndex)#uselib "WecApi.dll"
#func global EcInsertObjectArrayElement "EcInsertObjectArrayElement" sptr, sptr
; EcInsertObjectArrayElement ObjectArray, ArrayIndex ; 戻り値は stat
; ObjectArray : INT_PTR -> "sptr"
; ArrayIndex : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WecApi.dll"
#cfunc global EcInsertObjectArrayElement "EcInsertObjectArrayElement" sptr, int
; res = EcInsertObjectArrayElement(ObjectArray, ArrayIndex)
; ObjectArray : INT_PTR -> "sptr"
; ArrayIndex : DWORD -> "int"; BOOL EcInsertObjectArrayElement(INT_PTR ObjectArray, DWORD ArrayIndex)
#uselib "WecApi.dll"
#cfunc global EcInsertObjectArrayElement "EcInsertObjectArrayElement" intptr, int
; res = EcInsertObjectArrayElement(ObjectArray, ArrayIndex)
; ObjectArray : INT_PTR -> "intptr"
; ArrayIndex : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wecapi = windows.NewLazySystemDLL("WecApi.dll")
procEcInsertObjectArrayElement = wecapi.NewProc("EcInsertObjectArrayElement")
)
// ObjectArray (INT_PTR), ArrayIndex (DWORD)
r1, _, err := procEcInsertObjectArrayElement.Call(
uintptr(ObjectArray),
uintptr(ArrayIndex),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction EcInsertObjectArrayElement(
ObjectArray: NativeInt; // INT_PTR
ArrayIndex: DWORD // DWORD
): BOOL; stdcall;
external 'WecApi.dll' name 'EcInsertObjectArrayElement';result := DllCall("WecApi\EcInsertObjectArrayElement"
, "Ptr", ObjectArray ; INT_PTR
, "UInt", ArrayIndex ; DWORD
, "Int") ; return: BOOL●EcInsertObjectArrayElement(ObjectArray, ArrayIndex) = DLL("WecApi.dll", "bool EcInsertObjectArrayElement(int, dword)")
# 呼び出し: EcInsertObjectArrayElement(ObjectArray, ArrayIndex)
# ObjectArray : INT_PTR -> "int"
# ArrayIndex : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wecapi" fn EcInsertObjectArrayElement(
ObjectArray: isize, // INT_PTR
ArrayIndex: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc EcInsertObjectArrayElement(
ObjectArray: int, # INT_PTR
ArrayIndex: uint32 # DWORD
): int32 {.importc: "EcInsertObjectArrayElement", stdcall, dynlib: "WecApi.dll".}pragma(lib, "wecapi");
extern(Windows)
int EcInsertObjectArrayElement(
ptrdiff_t ObjectArray, // INT_PTR
uint ArrayIndex // DWORD
);ccall((:EcInsertObjectArrayElement, "WecApi.dll"), stdcall, Int32,
(Int, UInt32),
ObjectArray, ArrayIndex)
# ObjectArray : INT_PTR -> Int
# ArrayIndex : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t EcInsertObjectArrayElement(
intptr_t ObjectArray,
uint32_t ArrayIndex);
]]
local wecapi = ffi.load("wecapi")
-- wecapi.EcInsertObjectArrayElement(ObjectArray, ArrayIndex)
-- ObjectArray : INT_PTR
-- ArrayIndex : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WecApi.dll');
const EcInsertObjectArrayElement = lib.func('__stdcall', 'EcInsertObjectArrayElement', 'int32_t', ['intptr_t', 'uint32_t']);
// EcInsertObjectArrayElement(ObjectArray, ArrayIndex)
// ObjectArray : INT_PTR -> 'intptr_t'
// ArrayIndex : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WecApi.dll", {
EcInsertObjectArrayElement: { parameters: ["isize", "u32"], result: "i32" },
});
// lib.symbols.EcInsertObjectArrayElement(ObjectArray, ArrayIndex)
// ObjectArray : INT_PTR -> "isize"
// ArrayIndex : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t EcInsertObjectArrayElement(
intptr_t ObjectArray,
uint32_t ArrayIndex);
C, "WecApi.dll");
// $ffi->EcInsertObjectArrayElement(ObjectArray, ArrayIndex);
// ObjectArray : INT_PTR
// ArrayIndex : 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 Wecapi extends StdCallLibrary {
Wecapi INSTANCE = Native.load("wecapi", Wecapi.class);
boolean EcInsertObjectArrayElement(
long ObjectArray, // INT_PTR
int ArrayIndex // DWORD
);
}@[Link("wecapi")]
lib LibWecApi
fun EcInsertObjectArrayElement = EcInsertObjectArrayElement(
ObjectArray : LibC::SSizeT, # INT_PTR
ArrayIndex : 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 EcInsertObjectArrayElementNative = Int32 Function(IntPtr, Uint32);
typedef EcInsertObjectArrayElementDart = int Function(int, int);
final EcInsertObjectArrayElement = DynamicLibrary.open('WecApi.dll')
.lookupFunction<EcInsertObjectArrayElementNative, EcInsertObjectArrayElementDart>('EcInsertObjectArrayElement');
// ObjectArray : INT_PTR -> IntPtr
// ArrayIndex : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function EcInsertObjectArrayElement(
ObjectArray: NativeInt; // INT_PTR
ArrayIndex: DWORD // DWORD
): BOOL; stdcall;
external 'WecApi.dll' name 'EcInsertObjectArrayElement';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "EcInsertObjectArrayElement"
c_EcInsertObjectArrayElement :: CIntPtr -> Word32 -> IO CInt
-- ObjectArray : INT_PTR -> CIntPtr
-- ArrayIndex : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ecinsertobjectarrayelement =
foreign "EcInsertObjectArrayElement"
(intptr_t @-> uint32_t @-> returning int32_t)
(* ObjectArray : INT_PTR -> intptr_t *)
(* ArrayIndex : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wecapi (t "WecApi.dll"))
(cffi:use-foreign-library wecapi)
(cffi:defcfun ("EcInsertObjectArrayElement" ec-insert-object-array-element :convention :stdcall) :int32
(object-array :int64) ; INT_PTR
(array-index :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $EcInsertObjectArrayElement = Win32::API::More->new('WecApi',
'BOOL EcInsertObjectArrayElement(LPARAM ObjectArray, DWORD ArrayIndex)');
# my $ret = $EcInsertObjectArrayElement->Call($ObjectArray, $ArrayIndex);
# ObjectArray : INT_PTR -> LPARAM
# ArrayIndex : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。