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

WsReadCharsUtf8

関数
XMLからUTF-8文字列を読み取る。
DLLwebservices.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

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

パラメーター

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

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WsReadCharsUtf8(
    WS_XML_READER* reader,
    BYTE* bytes,
    DWORD maxByteCount,
    DWORD* actualByteCount,
    WS_ERROR* error   // optional
);
[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsReadCharsUtf8(
    ref IntPtr reader,   // WS_XML_READER*
    IntPtr bytes,   // BYTE* out
    uint maxByteCount,   // DWORD
    out uint actualByteCount,   // DWORD* out
    IntPtr error   // WS_ERROR* optional
);
<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsReadCharsUtf8(
    ByRef reader As IntPtr,   ' WS_XML_READER*
    bytes As IntPtr,   ' BYTE* 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 : BYTE* out
' maxByteCount : DWORD
' actualByteCount : DWORD* out
' error : WS_ERROR* optional
Declare PtrSafe Function WsReadCharsUtf8 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

WsReadCharsUtf8 = ctypes.windll.webservices.WsReadCharsUtf8
WsReadCharsUtf8.restype = ctypes.c_int
WsReadCharsUtf8.argtypes = [
    ctypes.c_void_p,  # reader : WS_XML_READER*
    ctypes.POINTER(ctypes.c_ubyte),  # bytes : BYTE* 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')
WsReadCharsUtf8 = Fiddle::Function.new(
  lib['WsReadCharsUtf8'],
  [
    Fiddle::TYPE_VOIDP,  # reader : WS_XML_READER*
    Fiddle::TYPE_VOIDP,  # bytes : BYTE* 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 WsReadCharsUtf8(
        reader: *mut isize,  // WS_XML_READER*
        bytes: *mut u8,  // BYTE* 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 WsReadCharsUtf8(ref IntPtr reader, IntPtr bytes, uint maxByteCount, out uint actualByteCount, IntPtr error);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsReadCharsUtf8' -Namespace Win32 -PassThru
# $api::WsReadCharsUtf8(reader, bytes, maxByteCount, actualByteCount, error)
#uselib "webservices.dll"
#func global WsReadCharsUtf8 "WsReadCharsUtf8" sptr, sptr, sptr, sptr, sptr
; WsReadCharsUtf8 reader, varptr(bytes), maxByteCount, varptr(actualByteCount), error   ; 戻り値は stat
; reader : WS_XML_READER* -> "sptr"
; bytes : BYTE* out -> "sptr"
; maxByteCount : DWORD -> "sptr"
; actualByteCount : DWORD* out -> "sptr"
; error : WS_ERROR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "webservices.dll"
#cfunc global WsReadCharsUtf8 "WsReadCharsUtf8" int, var, int, var, int
; res = WsReadCharsUtf8(reader, bytes, maxByteCount, actualByteCount, error)
; reader : WS_XML_READER* -> "int"
; bytes : BYTE* out -> "var"
; maxByteCount : DWORD -> "int"
; actualByteCount : DWORD* out -> "var"
; error : WS_ERROR* optional -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WsReadCharsUtf8(WS_XML_READER* reader, BYTE* bytes, DWORD maxByteCount, DWORD* actualByteCount, WS_ERROR* error)
#uselib "webservices.dll"
#cfunc global WsReadCharsUtf8 "WsReadCharsUtf8" int, var, int, var, int
; res = WsReadCharsUtf8(reader, bytes, maxByteCount, actualByteCount, error)
; reader : WS_XML_READER* -> "int"
; bytes : BYTE* out -> "var"
; 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")
	procWsReadCharsUtf8 = webservices.NewProc("WsReadCharsUtf8")
)

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