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

WsWriteXmlBufferToBytes

関数
XMLバッファをエンコードしてバイト列に出力する。
DLLwebservices.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

HRESULT WsWriteXmlBufferToBytes(
    WS_XML_WRITER* writer,
    WS_XML_BUFFER* xmlBuffer,
    const WS_XML_WRITER_ENCODING* encoding,   // optional
    const WS_XML_WRITER_PROPERTY* properties,   // optional
    DWORD propertyCount,
    WS_HEAP* heap,
    void** bytes,
    DWORD* byteCount,
    WS_ERROR* error   // optional
);

パラメーター

名前方向
writerWS_XML_WRITER*in
xmlBufferWS_XML_BUFFER*in
encodingWS_XML_WRITER_ENCODING*inoptional
propertiesWS_XML_WRITER_PROPERTY*inoptional
propertyCountDWORDin
heapWS_HEAP*in
bytesvoid**out
byteCountDWORD*out
errorWS_ERROR*inoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WsWriteXmlBufferToBytes(
    WS_XML_WRITER* writer,
    WS_XML_BUFFER* xmlBuffer,
    const WS_XML_WRITER_ENCODING* encoding,   // optional
    const WS_XML_WRITER_PROPERTY* properties,   // optional
    DWORD propertyCount,
    WS_HEAP* heap,
    void** bytes,
    DWORD* byteCount,
    WS_ERROR* error   // optional
);
[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsWriteXmlBufferToBytes(
    ref IntPtr writer,   // WS_XML_WRITER*
    ref IntPtr xmlBuffer,   // WS_XML_BUFFER*
    IntPtr encoding,   // WS_XML_WRITER_ENCODING* optional
    IntPtr properties,   // WS_XML_WRITER_PROPERTY* optional
    uint propertyCount,   // DWORD
    ref IntPtr heap,   // WS_HEAP*
    IntPtr bytes,   // void** out
    out uint byteCount,   // DWORD* out
    IntPtr error   // WS_ERROR* optional
);
<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsWriteXmlBufferToBytes(
    ByRef writer As IntPtr,   ' WS_XML_WRITER*
    ByRef xmlBuffer As IntPtr,   ' WS_XML_BUFFER*
    encoding As IntPtr,   ' WS_XML_WRITER_ENCODING* optional
    properties As IntPtr,   ' WS_XML_WRITER_PROPERTY* optional
    propertyCount As UInteger,   ' DWORD
    ByRef heap As IntPtr,   ' WS_HEAP*
    bytes As IntPtr,   ' void** out
    <Out> ByRef byteCount As UInteger,   ' DWORD* out
    [error] As IntPtr   ' WS_ERROR* optional
) As Integer
End Function
' writer : WS_XML_WRITER*
' xmlBuffer : WS_XML_BUFFER*
' encoding : WS_XML_WRITER_ENCODING* optional
' properties : WS_XML_WRITER_PROPERTY* optional
' propertyCount : DWORD
' heap : WS_HEAP*
' bytes : void** out
' byteCount : DWORD* out
' error : WS_ERROR* optional
Declare PtrSafe Function WsWriteXmlBufferToBytes Lib "webservices" ( _
    ByRef writer As LongPtr, _
    ByRef xmlBuffer As LongPtr, _
    ByVal encoding As LongPtr, _
    ByVal properties As LongPtr, _
    ByVal propertyCount As Long, _
    ByRef heap As LongPtr, _
    ByVal bytes As LongPtr, _
    ByRef byteCount 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

WsWriteXmlBufferToBytes = ctypes.windll.webservices.WsWriteXmlBufferToBytes
WsWriteXmlBufferToBytes.restype = ctypes.c_int
WsWriteXmlBufferToBytes.argtypes = [
    ctypes.c_void_p,  # writer : WS_XML_WRITER*
    ctypes.c_void_p,  # xmlBuffer : WS_XML_BUFFER*
    ctypes.c_void_p,  # encoding : WS_XML_WRITER_ENCODING* optional
    ctypes.c_void_p,  # properties : WS_XML_WRITER_PROPERTY* optional
    wintypes.DWORD,  # propertyCount : DWORD
    ctypes.c_void_p,  # heap : WS_HEAP*
    ctypes.c_void_p,  # bytes : void** out
    ctypes.POINTER(wintypes.DWORD),  # byteCount : DWORD* out
    ctypes.c_void_p,  # error : WS_ERROR* optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	webservices = windows.NewLazySystemDLL("webservices.dll")
	procWsWriteXmlBufferToBytes = webservices.NewProc("WsWriteXmlBufferToBytes")
)

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