ホーム › Networking.WindowsWebServices › WsReadArray
WsReadArray
関数XMLから値の配列を読み取る。
シグネチャ
// webservices.dll
#include <windows.h>
HRESULT WsReadArray(
WS_XML_READER* reader,
const WS_XML_STRING* localName,
const WS_XML_STRING* ns,
WS_VALUE_TYPE valueType,
void* array, // optional
DWORD arraySize,
DWORD itemOffset,
DWORD itemCount,
DWORD* actualItemCount,
WS_ERROR* error // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| reader | WS_XML_READER* | in | 配列要素を読み込む対象のXMLリーダー。 |
| localName | WS_XML_STRING* | in | 各配列項目のローカル名。 |
| ns | WS_XML_STRING* | in | 各配列項目の名前空間URI。 |
| valueType | WS_VALUE_TYPE | in | 配列要素の値型を示す列挙値。 |
| array | void* | outoptional | 読み込んだ要素を格納する出力配列へのポインタ。 |
| arraySize | DWORD | in | array全体のバイトサイズ。 |
| itemOffset | DWORD | in | 格納を開始する配列内の項目オフセット。 |
| itemCount | DWORD | in | 読み込もうとする項目数の上限。 |
| actualItemCount | DWORD* | out | 実際に読み込まれた項目数を受け取る出力ポインタ。 |
| error | WS_ERROR* | inoptional | 失敗時の追加エラー情報を格納するWS_ERRORオブジェクト。NULL可。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// webservices.dll
#include <windows.h>
HRESULT WsReadArray(
WS_XML_READER* reader,
const WS_XML_STRING* localName,
const WS_XML_STRING* ns,
WS_VALUE_TYPE valueType,
void* array, // optional
DWORD arraySize,
DWORD itemOffset,
DWORD itemCount,
DWORD* actualItemCount,
WS_ERROR* error // optional
);[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsReadArray(
ref IntPtr reader, // WS_XML_READER*
IntPtr localName, // WS_XML_STRING*
IntPtr ns, // WS_XML_STRING*
int valueType, // WS_VALUE_TYPE
IntPtr array, // void* optional, out
uint arraySize, // DWORD
uint itemOffset, // DWORD
uint itemCount, // DWORD
out uint actualItemCount, // DWORD* out
IntPtr error // WS_ERROR* optional
);<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsReadArray(
ByRef reader As IntPtr, ' WS_XML_READER*
localName As IntPtr, ' WS_XML_STRING*
ns As IntPtr, ' WS_XML_STRING*
valueType As Integer, ' WS_VALUE_TYPE
array As IntPtr, ' void* optional, out
arraySize As UInteger, ' DWORD
itemOffset As UInteger, ' DWORD
itemCount As UInteger, ' DWORD
<Out> ByRef actualItemCount As UInteger, ' DWORD* out
[error] As IntPtr ' WS_ERROR* optional
) As Integer
End Function' reader : WS_XML_READER*
' localName : WS_XML_STRING*
' ns : WS_XML_STRING*
' valueType : WS_VALUE_TYPE
' array : void* optional, out
' arraySize : DWORD
' itemOffset : DWORD
' itemCount : DWORD
' actualItemCount : DWORD* out
' error : WS_ERROR* optional
Declare PtrSafe Function WsReadArray Lib "webservices" ( _
ByRef reader As LongPtr, _
ByVal localName As LongPtr, _
ByVal ns As LongPtr, _
ByVal valueType As Long, _
ByVal array As LongPtr, _
ByVal arraySize As Long, _
ByVal itemOffset As Long, _
ByVal itemCount As Long, _
ByRef actualItemCount As Long, _
ByVal error As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WsReadArray = ctypes.windll.webservices.WsReadArray
WsReadArray.restype = ctypes.c_int
WsReadArray.argtypes = [
ctypes.c_void_p, # reader : WS_XML_READER*
ctypes.c_void_p, # localName : WS_XML_STRING*
ctypes.c_void_p, # ns : WS_XML_STRING*
ctypes.c_int, # valueType : WS_VALUE_TYPE
ctypes.POINTER(None), # array : void* optional, out
wintypes.DWORD, # arraySize : DWORD
wintypes.DWORD, # itemOffset : DWORD
wintypes.DWORD, # itemCount : DWORD
ctypes.POINTER(wintypes.DWORD), # actualItemCount : DWORD* out
ctypes.c_void_p, # error : WS_ERROR* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('webservices.dll')
WsReadArray = Fiddle::Function.new(
lib['WsReadArray'],
[
Fiddle::TYPE_VOIDP, # reader : WS_XML_READER*
Fiddle::TYPE_VOIDP, # localName : WS_XML_STRING*
Fiddle::TYPE_VOIDP, # ns : WS_XML_STRING*
Fiddle::TYPE_INT, # valueType : WS_VALUE_TYPE
Fiddle::TYPE_VOIDP, # array : void* optional, out
-Fiddle::TYPE_INT, # arraySize : DWORD
-Fiddle::TYPE_INT, # itemOffset : DWORD
-Fiddle::TYPE_INT, # itemCount : DWORD
Fiddle::TYPE_VOIDP, # actualItemCount : DWORD* out
Fiddle::TYPE_VOIDP, # error : WS_ERROR* optional
],
Fiddle::TYPE_INT)#[link(name = "webservices")]
extern "system" {
fn WsReadArray(
reader: *mut isize, // WS_XML_READER*
localName: *const WS_XML_STRING, // WS_XML_STRING*
ns: *const WS_XML_STRING, // WS_XML_STRING*
valueType: i32, // WS_VALUE_TYPE
array: *mut (), // void* optional, out
arraySize: u32, // DWORD
itemOffset: u32, // DWORD
itemCount: u32, // DWORD
actualItemCount: *mut u32, // DWORD* out
error: *mut isize // WS_ERROR* optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("webservices.dll")]
public static extern int WsReadArray(ref IntPtr reader, IntPtr localName, IntPtr ns, int valueType, IntPtr array, uint arraySize, uint itemOffset, uint itemCount, out uint actualItemCount, IntPtr error);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsReadArray' -Namespace Win32 -PassThru
# $api::WsReadArray(reader, localName, ns, valueType, array, arraySize, itemOffset, itemCount, actualItemCount, error)#uselib "webservices.dll"
#func global WsReadArray "WsReadArray" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WsReadArray varptr(reader), varptr(localName), varptr(ns), valueType, array, arraySize, itemOffset, itemCount, varptr(actualItemCount), varptr(error) ; 戻り値は stat
; reader : WS_XML_READER* -> "sptr"
; localName : WS_XML_STRING* -> "sptr"
; ns : WS_XML_STRING* -> "sptr"
; valueType : WS_VALUE_TYPE -> "sptr"
; array : void* optional, out -> "sptr"
; arraySize : DWORD -> "sptr"
; itemOffset : DWORD -> "sptr"
; itemCount : DWORD -> "sptr"
; actualItemCount : DWORD* out -> "sptr"
; error : WS_ERROR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "webservices.dll" #cfunc global WsReadArray "WsReadArray" var, var, var, int, sptr, int, int, int, var, var ; res = WsReadArray(reader, localName, ns, valueType, array, arraySize, itemOffset, itemCount, actualItemCount, error) ; reader : WS_XML_READER* -> "var" ; localName : WS_XML_STRING* -> "var" ; ns : WS_XML_STRING* -> "var" ; valueType : WS_VALUE_TYPE -> "int" ; array : void* optional, out -> "sptr" ; arraySize : DWORD -> "int" ; itemOffset : DWORD -> "int" ; itemCount : DWORD -> "int" ; actualItemCount : DWORD* out -> "var" ; error : WS_ERROR* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "webservices.dll" #cfunc global WsReadArray "WsReadArray" sptr, sptr, sptr, int, sptr, int, int, int, sptr, sptr ; res = WsReadArray(varptr(reader), varptr(localName), varptr(ns), valueType, array, arraySize, itemOffset, itemCount, varptr(actualItemCount), varptr(error)) ; reader : WS_XML_READER* -> "sptr" ; localName : WS_XML_STRING* -> "sptr" ; ns : WS_XML_STRING* -> "sptr" ; valueType : WS_VALUE_TYPE -> "int" ; array : void* optional, out -> "sptr" ; arraySize : DWORD -> "int" ; itemOffset : DWORD -> "int" ; itemCount : DWORD -> "int" ; actualItemCount : DWORD* out -> "sptr" ; error : WS_ERROR* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT WsReadArray(WS_XML_READER* reader, WS_XML_STRING* localName, WS_XML_STRING* ns, WS_VALUE_TYPE valueType, void* array, DWORD arraySize, DWORD itemOffset, DWORD itemCount, DWORD* actualItemCount, WS_ERROR* error) #uselib "webservices.dll" #cfunc global WsReadArray "WsReadArray" var, var, var, int, intptr, int, int, int, var, var ; res = WsReadArray(reader, localName, ns, valueType, array, arraySize, itemOffset, itemCount, actualItemCount, error) ; reader : WS_XML_READER* -> "var" ; localName : WS_XML_STRING* -> "var" ; ns : WS_XML_STRING* -> "var" ; valueType : WS_VALUE_TYPE -> "int" ; array : void* optional, out -> "intptr" ; arraySize : DWORD -> "int" ; itemOffset : DWORD -> "int" ; itemCount : DWORD -> "int" ; actualItemCount : DWORD* out -> "var" ; error : WS_ERROR* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WsReadArray(WS_XML_READER* reader, WS_XML_STRING* localName, WS_XML_STRING* ns, WS_VALUE_TYPE valueType, void* array, DWORD arraySize, DWORD itemOffset, DWORD itemCount, DWORD* actualItemCount, WS_ERROR* error) #uselib "webservices.dll" #cfunc global WsReadArray "WsReadArray" intptr, intptr, intptr, int, intptr, int, int, int, intptr, intptr ; res = WsReadArray(varptr(reader), varptr(localName), varptr(ns), valueType, array, arraySize, itemOffset, itemCount, varptr(actualItemCount), varptr(error)) ; reader : WS_XML_READER* -> "intptr" ; localName : WS_XML_STRING* -> "intptr" ; ns : WS_XML_STRING* -> "intptr" ; valueType : WS_VALUE_TYPE -> "int" ; array : void* optional, out -> "intptr" ; arraySize : DWORD -> "int" ; itemOffset : DWORD -> "int" ; itemCount : DWORD -> "int" ; actualItemCount : DWORD* out -> "intptr" ; error : WS_ERROR* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
webservices = windows.NewLazySystemDLL("webservices.dll")
procWsReadArray = webservices.NewProc("WsReadArray")
)
// reader (WS_XML_READER*), localName (WS_XML_STRING*), ns (WS_XML_STRING*), valueType (WS_VALUE_TYPE), array (void* optional, out), arraySize (DWORD), itemOffset (DWORD), itemCount (DWORD), actualItemCount (DWORD* out), error (WS_ERROR* optional)
r1, _, err := procWsReadArray.Call(
uintptr(reader),
uintptr(localName),
uintptr(ns),
uintptr(valueType),
uintptr(array),
uintptr(arraySize),
uintptr(itemOffset),
uintptr(itemCount),
uintptr(actualItemCount),
uintptr(error),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WsReadArray(
reader: Pointer; // WS_XML_READER*
localName: Pointer; // WS_XML_STRING*
ns: Pointer; // WS_XML_STRING*
valueType: Integer; // WS_VALUE_TYPE
array: Pointer; // void* optional, out
arraySize: DWORD; // DWORD
itemOffset: DWORD; // DWORD
itemCount: DWORD; // DWORD
actualItemCount: Pointer; // DWORD* out
error: Pointer // WS_ERROR* optional
): Integer; stdcall;
external 'webservices.dll' name 'WsReadArray';result := DllCall("webservices\WsReadArray"
, "Ptr", reader ; WS_XML_READER*
, "Ptr", localName ; WS_XML_STRING*
, "Ptr", ns ; WS_XML_STRING*
, "Int", valueType ; WS_VALUE_TYPE
, "Ptr", array ; void* optional, out
, "UInt", arraySize ; DWORD
, "UInt", itemOffset ; DWORD
, "UInt", itemCount ; DWORD
, "Ptr", actualItemCount ; DWORD* out
, "Ptr", error ; WS_ERROR* optional
, "Int") ; return: HRESULT●WsReadArray(reader, localName, ns, valueType, array, arraySize, itemOffset, itemCount, actualItemCount, error) = DLL("webservices.dll", "int WsReadArray(void*, void*, void*, int, void*, dword, dword, dword, void*, void*)")
# 呼び出し: WsReadArray(reader, localName, ns, valueType, array, arraySize, itemOffset, itemCount, actualItemCount, error)
# reader : WS_XML_READER* -> "void*"
# localName : WS_XML_STRING* -> "void*"
# ns : WS_XML_STRING* -> "void*"
# valueType : WS_VALUE_TYPE -> "int"
# array : void* optional, out -> "void*"
# arraySize : DWORD -> "dword"
# itemOffset : DWORD -> "dword"
# itemCount : DWORD -> "dword"
# actualItemCount : DWORD* out -> "void*"
# error : WS_ERROR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "webservices" fn WsReadArray(
reader: [*c]isize, // WS_XML_READER*
localName: [*c]WS_XML_STRING, // WS_XML_STRING*
ns: [*c]WS_XML_STRING, // WS_XML_STRING*
valueType: i32, // WS_VALUE_TYPE
array: ?*anyopaque, // void* optional, out
arraySize: u32, // DWORD
itemOffset: u32, // DWORD
itemCount: u32, // DWORD
actualItemCount: [*c]u32, // DWORD* out
error: [*c]isize // WS_ERROR* optional
) callconv(std.os.windows.WINAPI) i32;proc WsReadArray(
reader: ptr int, # WS_XML_READER*
localName: ptr WS_XML_STRING, # WS_XML_STRING*
ns: ptr WS_XML_STRING, # WS_XML_STRING*
valueType: int32, # WS_VALUE_TYPE
array: pointer, # void* optional, out
arraySize: uint32, # DWORD
itemOffset: uint32, # DWORD
itemCount: uint32, # DWORD
actualItemCount: ptr uint32, # DWORD* out
error: ptr int # WS_ERROR* optional
): int32 {.importc: "WsReadArray", stdcall, dynlib: "webservices.dll".}pragma(lib, "webservices");
extern(Windows)
int WsReadArray(
ptrdiff_t* reader, // WS_XML_READER*
WS_XML_STRING* localName, // WS_XML_STRING*
WS_XML_STRING* ns, // WS_XML_STRING*
int valueType, // WS_VALUE_TYPE
void* array, // void* optional, out
uint arraySize, // DWORD
uint itemOffset, // DWORD
uint itemCount, // DWORD
uint* actualItemCount, // DWORD* out
ptrdiff_t* error // WS_ERROR* optional
);ccall((:WsReadArray, "webservices.dll"), stdcall, Int32,
(Ptr{Int}, Ptr{WS_XML_STRING}, Ptr{WS_XML_STRING}, Int32, Ptr{Cvoid}, UInt32, UInt32, UInt32, Ptr{UInt32}, Ptr{Int}),
reader, localName, ns, valueType, array, arraySize, itemOffset, itemCount, actualItemCount, error)
# reader : WS_XML_READER* -> Ptr{Int}
# localName : WS_XML_STRING* -> Ptr{WS_XML_STRING}
# ns : WS_XML_STRING* -> Ptr{WS_XML_STRING}
# valueType : WS_VALUE_TYPE -> Int32
# array : void* optional, out -> Ptr{Cvoid}
# arraySize : DWORD -> UInt32
# itemOffset : DWORD -> UInt32
# itemCount : DWORD -> UInt32
# actualItemCount : DWORD* out -> Ptr{UInt32}
# error : WS_ERROR* optional -> Ptr{Int}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WsReadArray(
intptr_t* reader,
void* localName,
void* ns,
int32_t valueType,
void* array,
uint32_t arraySize,
uint32_t itemOffset,
uint32_t itemCount,
uint32_t* actualItemCount,
intptr_t* error);
]]
local webservices = ffi.load("webservices")
-- webservices.WsReadArray(reader, localName, ns, valueType, array, arraySize, itemOffset, itemCount, actualItemCount, error)
-- reader : WS_XML_READER*
-- localName : WS_XML_STRING*
-- ns : WS_XML_STRING*
-- valueType : WS_VALUE_TYPE
-- array : void* optional, out
-- arraySize : DWORD
-- itemOffset : DWORD
-- itemCount : DWORD
-- actualItemCount : DWORD* out
-- error : WS_ERROR* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('webservices.dll');
const WsReadArray = lib.func('__stdcall', 'WsReadArray', 'int32_t', ['intptr_t *', 'void *', 'void *', 'int32_t', 'void *', 'uint32_t', 'uint32_t', 'uint32_t', 'uint32_t *', 'intptr_t *']);
// WsReadArray(reader, localName, ns, valueType, array, arraySize, itemOffset, itemCount, actualItemCount, error)
// reader : WS_XML_READER* -> 'intptr_t *'
// localName : WS_XML_STRING* -> 'void *'
// ns : WS_XML_STRING* -> 'void *'
// valueType : WS_VALUE_TYPE -> 'int32_t'
// array : void* optional, out -> 'void *'
// arraySize : DWORD -> 'uint32_t'
// itemOffset : DWORD -> 'uint32_t'
// itemCount : DWORD -> 'uint32_t'
// actualItemCount : DWORD* out -> 'uint32_t *'
// error : WS_ERROR* optional -> 'intptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("webservices.dll", {
WsReadArray: { parameters: ["pointer", "pointer", "pointer", "i32", "pointer", "u32", "u32", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WsReadArray(reader, localName, ns, valueType, array, arraySize, itemOffset, itemCount, actualItemCount, error)
// reader : WS_XML_READER* -> "pointer"
// localName : WS_XML_STRING* -> "pointer"
// ns : WS_XML_STRING* -> "pointer"
// valueType : WS_VALUE_TYPE -> "i32"
// array : void* optional, out -> "pointer"
// arraySize : DWORD -> "u32"
// itemOffset : DWORD -> "u32"
// itemCount : DWORD -> "u32"
// actualItemCount : DWORD* out -> "pointer"
// error : WS_ERROR* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WsReadArray(
intptr_t* reader,
void* localName,
void* ns,
int32_t valueType,
void* array,
uint32_t arraySize,
uint32_t itemOffset,
uint32_t itemCount,
uint32_t* actualItemCount,
intptr_t* error);
C, "webservices.dll");
// $ffi->WsReadArray(reader, localName, ns, valueType, array, arraySize, itemOffset, itemCount, actualItemCount, error);
// reader : WS_XML_READER*
// localName : WS_XML_STRING*
// ns : WS_XML_STRING*
// valueType : WS_VALUE_TYPE
// array : void* optional, out
// arraySize : DWORD
// itemOffset : DWORD
// itemCount : DWORD
// actualItemCount : DWORD* out
// error : WS_ERROR* 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 Webservices extends StdCallLibrary {
Webservices INSTANCE = Native.load("webservices", Webservices.class);
int WsReadArray(
LongByReference reader, // WS_XML_READER*
Pointer localName, // WS_XML_STRING*
Pointer ns, // WS_XML_STRING*
int valueType, // WS_VALUE_TYPE
Pointer array, // void* optional, out
int arraySize, // DWORD
int itemOffset, // DWORD
int itemCount, // DWORD
IntByReference actualItemCount, // DWORD* out
LongByReference error // WS_ERROR* optional
);
}@[Link("webservices")]
lib Libwebservices
fun WsReadArray = WsReadArray(
reader : LibC::SSizeT*, # WS_XML_READER*
localName : WS_XML_STRING*, # WS_XML_STRING*
ns : WS_XML_STRING*, # WS_XML_STRING*
valueType : Int32, # WS_VALUE_TYPE
array : Void*, # void* optional, out
arraySize : UInt32, # DWORD
itemOffset : UInt32, # DWORD
itemCount : UInt32, # DWORD
actualItemCount : UInt32*, # DWORD* out
error : LibC::SSizeT* # WS_ERROR* optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WsReadArrayNative = Int32 Function(Pointer<IntPtr>, Pointer<Void>, Pointer<Void>, Int32, Pointer<Void>, Uint32, Uint32, Uint32, Pointer<Uint32>, Pointer<IntPtr>);
typedef WsReadArrayDart = int Function(Pointer<IntPtr>, Pointer<Void>, Pointer<Void>, int, Pointer<Void>, int, int, int, Pointer<Uint32>, Pointer<IntPtr>);
final WsReadArray = DynamicLibrary.open('webservices.dll')
.lookupFunction<WsReadArrayNative, WsReadArrayDart>('WsReadArray');
// reader : WS_XML_READER* -> Pointer<IntPtr>
// localName : WS_XML_STRING* -> Pointer<Void>
// ns : WS_XML_STRING* -> Pointer<Void>
// valueType : WS_VALUE_TYPE -> Int32
// array : void* optional, out -> Pointer<Void>
// arraySize : DWORD -> Uint32
// itemOffset : DWORD -> Uint32
// itemCount : DWORD -> Uint32
// actualItemCount : DWORD* out -> Pointer<Uint32>
// error : WS_ERROR* optional -> Pointer<IntPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WsReadArray(
reader: Pointer; // WS_XML_READER*
localName: Pointer; // WS_XML_STRING*
ns: Pointer; // WS_XML_STRING*
valueType: Integer; // WS_VALUE_TYPE
array: Pointer; // void* optional, out
arraySize: DWORD; // DWORD
itemOffset: DWORD; // DWORD
itemCount: DWORD; // DWORD
actualItemCount: Pointer; // DWORD* out
error: Pointer // WS_ERROR* optional
): Integer; stdcall;
external 'webservices.dll' name 'WsReadArray';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WsReadArray"
c_WsReadArray :: Ptr CIntPtr -> Ptr () -> Ptr () -> Int32 -> Ptr () -> Word32 -> Word32 -> Word32 -> Ptr Word32 -> Ptr CIntPtr -> IO Int32
-- reader : WS_XML_READER* -> Ptr CIntPtr
-- localName : WS_XML_STRING* -> Ptr ()
-- ns : WS_XML_STRING* -> Ptr ()
-- valueType : WS_VALUE_TYPE -> Int32
-- array : void* optional, out -> Ptr ()
-- arraySize : DWORD -> Word32
-- itemOffset : DWORD -> Word32
-- itemCount : DWORD -> Word32
-- actualItemCount : DWORD* out -> Ptr Word32
-- error : WS_ERROR* optional -> Ptr CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wsreadarray =
foreign "WsReadArray"
((ptr intptr_t) @-> (ptr void) @-> (ptr void) @-> int32_t @-> (ptr void) @-> uint32_t @-> uint32_t @-> uint32_t @-> (ptr uint32_t) @-> (ptr intptr_t) @-> returning int32_t)
(* reader : WS_XML_READER* -> (ptr intptr_t) *)
(* localName : WS_XML_STRING* -> (ptr void) *)
(* ns : WS_XML_STRING* -> (ptr void) *)
(* valueType : WS_VALUE_TYPE -> int32_t *)
(* array : void* optional, out -> (ptr void) *)
(* arraySize : DWORD -> uint32_t *)
(* itemOffset : DWORD -> uint32_t *)
(* itemCount : DWORD -> uint32_t *)
(* actualItemCount : DWORD* out -> (ptr uint32_t) *)
(* error : WS_ERROR* optional -> (ptr intptr_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library webservices (t "webservices.dll"))
(cffi:use-foreign-library webservices)
(cffi:defcfun ("WsReadArray" ws-read-array :convention :stdcall) :int32
(reader :pointer) ; WS_XML_READER*
(local-name :pointer) ; WS_XML_STRING*
(ns :pointer) ; WS_XML_STRING*
(value-type :int32) ; WS_VALUE_TYPE
(array :pointer) ; void* optional, out
(array-size :uint32) ; DWORD
(item-offset :uint32) ; DWORD
(item-count :uint32) ; DWORD
(actual-item-count :pointer) ; DWORD* out
(error :pointer)) ; WS_ERROR* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WsReadArray = Win32::API::More->new('webservices',
'int WsReadArray(LPVOID reader, LPVOID localName, LPVOID ns, int valueType, LPVOID array, DWORD arraySize, DWORD itemOffset, DWORD itemCount, LPVOID actualItemCount, LPVOID error)');
# my $ret = $WsReadArray->Call($reader, $localName, $ns, $valueType, $array, $arraySize, $itemOffset, $itemCount, $actualItemCount, $error);
# reader : WS_XML_READER* -> LPVOID
# localName : WS_XML_STRING* -> LPVOID
# ns : WS_XML_STRING* -> LPVOID
# valueType : WS_VALUE_TYPE -> int
# array : void* optional, out -> LPVOID
# arraySize : DWORD -> DWORD
# itemOffset : DWORD -> DWORD
# itemCount : DWORD -> DWORD
# actualItemCount : DWORD* out -> LPVOID
# error : WS_ERROR* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。