Win32 API 日本語リファレンス
ホームNetworking.WindowsWebServices › WsReadBytes

WsReadBytes

関数
XMLからバイト列を読み取る。
DLLwebservices.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

HRESULT WsReadBytes(
    WS_XML_READER* reader,
    void* bytes,
    DWORD maxByteCount,
    DWORD* actualByteCount,
    WS_ERROR* error   // optional
);

パラメーター

名前方向
readerWS_XML_READER*in
bytesvoid*out
maxByteCountDWORDin
actualByteCountDWORD*out
errorWS_ERROR*inoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WsReadBytes(
    WS_XML_READER* reader,
    void* bytes,
    DWORD maxByteCount,
    DWORD* actualByteCount,
    WS_ERROR* error   // optional
);
[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsReadBytes(
    ref IntPtr reader,   // WS_XML_READER*
    IntPtr bytes,   // void* out
    uint maxByteCount,   // DWORD
    out uint actualByteCount,   // DWORD* out
    IntPtr error   // WS_ERROR* optional
);
<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsReadBytes(
    ByRef reader As IntPtr,   ' WS_XML_READER*
    bytes As IntPtr,   ' void* out
    maxByteCount As UInteger,   ' DWORD
    <Out> ByRef actualByteCount As UInteger,   ' DWORD* out
    [error] As IntPtr   ' WS_ERROR* optional
) As Integer
End Function
' reader : WS_XML_READER*
' bytes : void* out
' maxByteCount : DWORD
' actualByteCount : DWORD* out
' error : WS_ERROR* optional
Declare PtrSafe Function WsReadBytes Lib "webservices" ( _
    ByRef reader As LongPtr, _
    ByVal bytes As LongPtr, _
    ByVal maxByteCount As Long, _
    ByRef actualByteCount 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

WsReadBytes = ctypes.windll.webservices.WsReadBytes
WsReadBytes.restype = ctypes.c_int
WsReadBytes.argtypes = [
    ctypes.c_void_p,  # reader : WS_XML_READER*
    ctypes.POINTER(None),  # bytes : void* out
    wintypes.DWORD,  # maxByteCount : DWORD
    ctypes.POINTER(wintypes.DWORD),  # actualByteCount : DWORD* out
    ctypes.c_void_p,  # error : WS_ERROR* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('webservices.dll')
WsReadBytes = Fiddle::Function.new(
  lib['WsReadBytes'],
  [
    Fiddle::TYPE_VOIDP,  # reader : WS_XML_READER*
    Fiddle::TYPE_VOIDP,  # bytes : void* out
    -Fiddle::TYPE_INT,  # maxByteCount : DWORD
    Fiddle::TYPE_VOIDP,  # actualByteCount : DWORD* out
    Fiddle::TYPE_VOIDP,  # error : WS_ERROR* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "webservices")]
extern "system" {
    fn WsReadBytes(
        reader: *mut isize,  // WS_XML_READER*
        bytes: *mut (),  // void* out
        maxByteCount: u32,  // DWORD
        actualByteCount: *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 WsReadBytes(ref IntPtr reader, IntPtr bytes, uint maxByteCount, out uint actualByteCount, IntPtr error);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsReadBytes' -Namespace Win32 -PassThru
# $api::WsReadBytes(reader, bytes, maxByteCount, actualByteCount, error)
#uselib "webservices.dll"
#func global WsReadBytes "WsReadBytes" sptr, sptr, sptr, sptr, sptr
; WsReadBytes reader, bytes, maxByteCount, varptr(actualByteCount), error   ; 戻り値は stat
; reader : WS_XML_READER* -> "sptr"
; bytes : void* out -> "sptr"
; maxByteCount : DWORD -> "sptr"
; actualByteCount : DWORD* out -> "sptr"
; error : WS_ERROR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "webservices.dll"
#cfunc global WsReadBytes "WsReadBytes" int, sptr, int, var, int
; res = WsReadBytes(reader, bytes, maxByteCount, actualByteCount, error)
; reader : WS_XML_READER* -> "int"
; bytes : void* out -> "sptr"
; maxByteCount : DWORD -> "int"
; actualByteCount : DWORD* out -> "var"
; error : WS_ERROR* optional -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WsReadBytes(WS_XML_READER* reader, void* bytes, DWORD maxByteCount, DWORD* actualByteCount, WS_ERROR* error)
#uselib "webservices.dll"
#cfunc global WsReadBytes "WsReadBytes" int, intptr, int, var, int
; res = WsReadBytes(reader, bytes, maxByteCount, actualByteCount, error)
; reader : WS_XML_READER* -> "int"
; bytes : void* out -> "intptr"
; maxByteCount : DWORD -> "int"
; actualByteCount : DWORD* out -> "var"
; error : WS_ERROR* optional -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	webservices = windows.NewLazySystemDLL("webservices.dll")
	procWsReadBytes = webservices.NewProc("WsReadBytes")
)

// reader (WS_XML_READER*), bytes (void* out), maxByteCount (DWORD), actualByteCount (DWORD* out), error (WS_ERROR* optional)
r1, _, err := procWsReadBytes.Call(
	uintptr(reader),
	uintptr(bytes),
	uintptr(maxByteCount),
	uintptr(actualByteCount),
	uintptr(error),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WsReadBytes(
  reader: Pointer;   // WS_XML_READER*
  bytes: Pointer;   // void* out
  maxByteCount: DWORD;   // DWORD
  actualByteCount: Pointer;   // DWORD* out
  error: Pointer   // WS_ERROR* optional
): Integer; stdcall;
  external 'webservices.dll' name 'WsReadBytes';
result := DllCall("webservices\WsReadBytes"
    , "Ptr", reader   ; WS_XML_READER*
    , "Ptr", bytes   ; void* out
    , "UInt", maxByteCount   ; DWORD
    , "Ptr", actualByteCount   ; DWORD* out
    , "Ptr", error   ; WS_ERROR* optional
    , "Int")   ; return: HRESULT
●WsReadBytes(reader, bytes, maxByteCount, actualByteCount, error) = DLL("webservices.dll", "int WsReadBytes(void*, void*, dword, void*, void*)")
# 呼び出し: WsReadBytes(reader, bytes, maxByteCount, actualByteCount, error)
# reader : WS_XML_READER* -> "void*"
# bytes : void* out -> "void*"
# maxByteCount : DWORD -> "dword"
# actualByteCount : DWORD* out -> "void*"
# error : WS_ERROR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。